I had some integration testing cases, they ran as Junit test cases with a special category:
@Category(IntegrationTest.class)
Because they are integration testing cases, so the cost of every steps is high. Usually I will re-use some results from previous steps to reduce this cost. To make it works, I added this into them:
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
Some samples like this:
@Category(IntegrationTest.class)
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class TestAllocationPlanApi {
@Test
public void testStep01_verifyOrigProgram22275() {...}
@Test
public void testStep02_CopyProgram() {...}
}
They work well except the failure process:
If step01 failed, we don't need to run step02, but Junit still go to step02.
It is a waste and makes the test cases more complicated because you need to carefully handle those variables which are passed into step02.
I tried
-Dsurefire.skipAfterFailureCount=1
Which is discussed in another thread, but it doesn't work, the test cases still go to next step if previous steps fails.
Another annoying thing about the test cases is that Junit always resets all instance variables before every step. This forces me to use static variable to pass previous result into next step:
private static Integer contractAId;
And I have no way to run them in multiple threads.
Does anybody have good ideas to handle those things?
Thanks!
Happy new year!