Doraryn Doraryn - 1 year ago 72
Java Question

How do I run tests using maven if I have multiple test classes with multiple tests in them which are prioritized?

I have 6 test classes, in each I have around 5 tests, which are prioritized.
When I run the test suit using maven, the test classes are combined somehow.
While the tests are not finished from a test class, another one starts, and fails my tests.
Is there a way, to run 1 test class with all of its tests first, and to run the second class after the first one is finished and so on?
Note: I run the test using a mvn command in Terminal.

Answer Source

Each class should have its own set-up and tear-down mechanism, so that the tests of different test classes are completely independent of each other. If several tests use a common resource that is expensive, put these tests together in one class and create the resource in the set-up method.

If you absolutely need to call some methods in a given order, you have write a test method which calls these methods (in the specified order). But you should try to avoid this as much as possible.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download