Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running junit tests in intelliJ in parallel [duplicate]

Tags:

Is it possible to run junit tests in intelliJ in parallel? If so, how do i do this?

I set the "fork" parameter to class level and this didn't do anything - actually, it made everything a bit slower, so i'm unsure what "fork" does that is beneficial?

Is it possible to do this just using intelliJ, or do i need some fancy test framework and all the hoo-hah that that would involve?

Finally, assuming this is at all possible, can one control the number of forks or threads or whatever they want to call it?

UPDATE: somebody has linked to a question that might answer this. I looked at that question prior to posting - I'm unsure what that question really "answers". It simply says there is an issue tracker and that this issue has been implemented in intelliJ. I don't see how to implement it anywhere.

UPDATE: What does "didn't do anything" mean?: it just makes things slower, which isn't v. useful. I mean, maybe your tests run blazingly quickly and you want to slow them down to appreciate some Bach? That is cool. I just want mine to run faster, I'm fed up of Bach.

like image 432
bharal Avatar asked Apr 16 '13 16:04

bharal


People also ask

Does IntelliJ run tests in parallel?

Answering late for posterity. You can make JUnit tests run in parallel (or serial) to any level of granularity in IntelliJ by changing the Fork mode in the test's run configuration. Be careful not to confuse this with the Allow parallel run option, which lets you start the test execution multiple times within your IDE.

Does JUnit run tests in parallel?

Once the parallel execution property is set (or enabled), the JUnit Jupiter engine will run the tests in parallel as per the configurations provided with the synchronization mechanisms.

Does JUnit 4 run tests in parallel?

A plugin that allows you to run JUnit4 tests in parallel (using multiple CPU cores/threads).


1 Answers

You can make use of the junit-toolbox. This is an extension library for jUnit that is listed on the jUnit site itself.

This extension offers the ParallelSuite. Through this you can create with nearly no effort an AllTest class that executes the tests in parallel. The minimum AllTest could look like the code below, using the pattern feature introduced with junit-toolbox.

@RunWith(ParallelSuite.class) @SuiteClasses("**/*Test.class") public class AllTests {} 

This will create as many threads for parallel execution as your JVM reports via availableProcessors. To override this you may set the system property maxParallelTestThreads.

like image 109
cheffe Avatar answered Sep 18 '22 12:09

cheffe