cancel
Showing results for 
Search instead for 
Did you mean: 

Deployment annotation in unit test: undeploy does not work

sor1
Champ in-the-making
Champ in-the-making
With V 5.9, in a unit test, if I use the deployment annotation , it is said in the user guide that the process should be undeployed at the end of the test but it is not the case:

   @Test
    @Deployment(resources = { "com/toto/MyProcess.bpmn20.xml" })
    public void testMyProcess()
    {
        […]
        runtimeService.startProcessInstanceByKey(mProcessInstanceKey);
        […]
    }

In activiti explorer, the process is still present in the deployment list; its name is the name of my test.
What's wrong? What should I do to undeploy automatically the deployment of MyProcess.bpmn20.xml?
5 REPLIES 5

ronald_van_kuij
Champ on-the-rise
Champ on-the-rise
Did you also use this?

@Rule
  public ActivitiRule activitiRule = new ActivitiRule();

ronald_van_kuij
Champ on-the-rise
Champ on-the-rise
hmmm you most likely are, otherwise the @Deployment would not work… hmmmm

frederikherema1
Star Contributor
Star Contributor
That's really strange. Didn't you see any exception when running the test?

Because, the ActivitiRule overrides the "finished()" to undeploy, called by JUnit in a finally-block. So when undeploying was unsuccessful, you should have seen
a stacktrace (@see ActivitiRule:118).

sor1
Champ in-the-making
Champ in-the-making
My test is successful.

If I add the advised lines:
@Rule
    public ActivitiRule activitiRule = new ActivitiRule();

The result is the same.

frederikherema1
Star Contributor
Star Contributor
I presume you're testing against an in-memort H2 database? Are you 100% sure you didn't deploy the process manually through explore and NO exception stack traces are shown in the console (even though your test is successful, still look at sys out). Because the code is what it is… If undeploying fails, you should see it and the reason…