In this post, I asked a small question as part of a bigger problem. Since I didn't get responses yet, I put my question here:
Is it reasonable to suppose that JUnit executes test cases sequentially: a test case ends befores the next one starts. Does it differ between JUnit versions (my priority is on JUnit4)? And if not, is there a simple way to force JUnit to execute tests sequentially?
Thank you
1. Overview. By default, JUnit runs tests using a deterministic but unpredictable order (MethodSorters. DEFAULT).
In JUnit, you can use @FixMethodOrder(MethodSorters. NAME_ASCENDING) to run the test methods by method name, in lexicographic order.
By default, unit testing libraries don't try to execute tests in the order that occurs in the source file.
Yes, by default I believe it runs tests sequentially.
JUnit 4.6 introduced an experimental ParallelRunner
to run tests in parallel - I don't know of its current status. I would expect parallelism to remain an "opt-in" feature by default though. (Judging by other answers, it looks like this is now here to stay but in a slightly different form - and still opt-in.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With