JUnit has an annotation @FixMethodOrder
to execute test methods in a given class in declaration order or in alphabetical order.
Surefire has a property runOrder
to start test classes in a given order, e.g. alphabetically.
Question
I have a test class with 2 methods. These are called simultanously by the maven, so:
It weren't a problem (I like concurrent things), but currently I need to somehow guarantee these tests to be called ordently. Thus I want to start testB only after testA is ready.
I am thinking about some like a dependency between these test methods. Is it somehow possible?
Solution 2
JUnit has an annotation @FixMethodOrder
to execute test methods in a given class in declaration order or in alphabetical order.
Surefire has a property runOrder
to start test classes in a given order, e.g. alphabetically.
OTHER TIPS
I don't think there is a simple way to do this with the surefire
plugin alone. As the other answer indicates you can do this with a combination of techniques.
Regardless, this is a bad practice. Unit tests should be independent. If you have a real dependency with them, you should combine them into a single test. Even if you can get this to work the way you want you will be working against the standard practice which will confuse others and make your setup hard to understand and maintain.