Will JUnit run a parallel test?

I wrote a JUnit test. I would like to know if tests in a test class can work in parallel.

class TestMyClass { @Test public void test1() { } @Test public void test2() { } } 

Will Junit run tests test1 () and test2 () in parallel?

+4
source share
4 answers

Consider TestNG if you are looking for Running Parallel Tests .

+4
source

Yes, you can. Take a look at this question to find out how to install it. True, the correctness of your tests should not really. Your tests should run correctly if they run at the same time or not.

+1
source

I cannot directly answer whether jUnit will run them in parallel or not, but theoretically it does not matter. The only thing you should keep in mind is the execution sequence that you can bet on, for example

  • Customization
  • test execution
  • dismantling

This should be sufficient, since each individual test should be completely independent of each other. If your tests depend on the order that they run, or they run in parallel, then you probably have some incorrect dependencies.

+1
source

No, because the instrument is installed before each test. Running the test in parallel can change the status of the device. I think you could write a test runner for running tests in parallel.

0
source

Source: https://habr.com/ru/post/1435366/


All Articles