# Is it possible to autoload process definitions in the test class path?

**URL:** <https://forum.flowable.org/t/is-it-possible-to-autoload-process-definitions-in-the-test-class-path/5466>\
**Category:** Flowable Engine\
**Created:** [February 17, 2020, 5:25pm UTC](https://forum.flowable.org/t/is-it-possible-to-autoload-process-definitions-in-the-test-class-path/5466 "2020-02-17T17:25:27Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![DarkStar1](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/darkstar1/32/394_2.png) [@DarkStar1](https://forum.flowable.org/u/DarkStar1)\
**Post date:** [February 17, 2020, 5:25pm UTC](https://forum.flowable.org/t/is-it-possible-to-autoload-process-definitions-in-the-test-class-path/5466/1 "2020-02-17T17:25:27Z")

</div>

I was wondering if it is possible to load process definitions in the test classpath or if the auto-loading mechanism will automatically will pick up the resources from a path in the test path?  
Currently trying to create a deployment by configuring the process engine bean in a test configuration class results in an error:

```auto
@Bean
public RepositoryService repositoryService(ProcessEngine processEngine) {
    // Load bpmn from the test classes
    processEngine.getRepositoryService().createDeployment().addClasspathResource("src/test/resources/processes/test-process.bpmn20.xml");
    return processEngine.getRepositoryService();
}

```

---

<div class="post-metadata">

**Author:** ![wwitt](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/wwitt/32/706_2.png) [@wwitt](https://forum.flowable.org/u/wwitt)\
**Post date:** [February 18, 2020, 3:14pm UTC](https://forum.flowable.org/t/is-it-possible-to-autoload-process-definitions-in-the-test-class-path/5466/2 "2020-02-18T15:14:25Z")

</div>

The preferred method is to use `@Deployment` and either name the test process appropriately or use a resource argument to specify the process under test.  
Here are the [docs](https://flowable.com/open-source/docs/bpmn/ch05-Spring/#unit-testing)

Some notes,

- the class loader usually puts the contents of the resources folder
- you need execute `.deploy()` to get the process deployed to the engine

```auto
repositoryService.createDeployment().addClasspathResource("processes/test-process.bpmn20.xml").name("test-process").deploy();

```

---

<div class="post-metadata">

**Author:** ![filiphr](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/filiphr/32/315_2.png) [@filiphr](https://forum.flowable.org/u/filiphr)\
**Post date:** [February 19, 2020, 7:26am UTC](https://forum.flowable.org/t/is-it-possible-to-autoload-process-definitions-in-the-test-class-path/5466/3 "2020-02-19T07:26:29Z")

</div>

If you are using Spring Boot then the auto loading mechanism for production is the same for the tests.

By default Spring Boot configured Engine would try to load all process definitions from the `processes/` directory (both from the test and production paths).

For specific tests of course the answer from @wwitt stands

---

<div class="post-metadata">

**Author:** ![DarkStar1](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/darkstar1/32/394_2.png) [@DarkStar1](https://forum.flowable.org/u/DarkStar1)\
**Post date:** [February 19, 2020, 8:48am UTC](https://forum.flowable.org/t/is-it-possible-to-autoload-process-definitions-in-the-test-class-path/5466/4 "2020-02-19T08:48:19Z")

</div>

I am using springboot and I added processes to my `src/test/resources/processes` however when I query for deployments:

```auto
List<Deployment> deploymentList = repositoryService.createDeploymentQuery().list();

```

I get a 0 count.

---

<div class="post-metadata">

**Author:** ![joram](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/joram/32/26_2.png) [@joram](https://forum.flowable.org/u/joram)\
**Post date:** [February 19, 2020, 7:08pm UTC](https://forum.flowable.org/t/is-it-possible-to-autoload-process-definitions-in-the-test-class-path/5466/5 "2020-02-19T19:08:08Z")

</div>

That should work indeed …  
How are you configuring your test? Can you paste more of the full unit test so we can reproduce?
