MichaelTamm / junit-toolbox

Useful classes for writing automated tests with JUnit 4
Other
140 stars 25 forks source link

ParallelSuite allow to specify to only run test classes in parallel and not each test method #19

Closed davsclaus closed 6 years ago

davsclaus commented 7 years ago

Hi

We are looking into running a several thousand test classes in parallel. However the @ParallelSuite annotation run each @Test method in the classes in parallel. What we would like to be able to do is to specify that it should only run the classes in parallel, not the test methods.

So if we can do specify this somehow. For example with a @SuiteConfiguration annotation

@RunWith(ParallelSuite.class)
@SuiteClasses("util/**/*Test.class")
@SuiteConfiguration(parallel = "classes")
public class MyParallelTests {

}

where we specify that parallel = "classes" which is similar to maven-surefire-plugin which has such an option: http://maven.apache.org/surefire/maven-surefire-plugin/examples/fork-options-and-parallel-execution.html

MichaelTamm commented 7 years ago

I would gladly accept a pull request for this feature. Any volunteers out there?

davsclaus commented 7 years ago

Yeah I wish I had time to dive into this as its my need for the Apache Camel project. However I am busy with upcoming house improvements, business travel, and finishing a book.

For full disclosure this is the Apache Camel JIRA ticket we have about running tests faster in parallel: https://issues.apache.org/jira/browse/CAMEL-11525

davsclaus commented 7 years ago

And btw we cannot run each test method in parallel, because the original tests were written without parallel runs many years ago, and they often assume that a test class is run by a single thread so it can safely read/write to a specific folder in target directory etc. And also initialize the Camel container once etc.

MichaelTamm commented 6 years ago

The ParallelSuite does, what it is supposed to do: It runs test classes in parallel. If you want to execute the test methods of a certain test class to run concurrently, you should use the ParallelRunner.