forked from MichaelTamm/junit-toolbox
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added ParallelInnerTestClassesSuite -- resolves MichaelTamm#23
- Loading branch information
1 parent
40a8a33
commit f069862
Showing
2 changed files
with
70 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
src/main/java/com/googlecode/junittoolbox/ParallelInnerTestClassesSuite.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package com.googlecode.junittoolbox; | ||
|
||
import org.junit.experimental.runners.Enclosed; | ||
import org.junit.runners.model.InitializationError; | ||
import org.junit.runners.model.RunnerBuilder; | ||
|
||
/** | ||
* Runs all inner test classes of the class | ||
* annotated with <code>@RunWith(ParallelInnerTestClassesSuite.class)</code>. | ||
* It executes its children classes concurrently. You can specify the maximum number | ||
* of parallel test threads using the system property <code>maxParallelTestThreads</code>. | ||
* If this system property is not specified, the maximum number of test threads | ||
* will be the number of {@link Runtime#availableProcessors() available processors.} | ||
* In contrast to the {@link Enclosed} runner provided by | ||
* <a href="http://junit.org/" target="_blank">JUnit</a>, | ||
* it detects if an inner class is actually a test class | ||
* and ignores all other inner classes. | ||
* Example:<pre> | ||
* @RunWith(ParallelInnerTestClassesSuite.class) | ||
* public class LoginBeanTests { | ||
* | ||
* public static class UnitTests { | ||
* @Test | ||
* public void test1() { ... } | ||
* } | ||
* | ||
* @Configuration | ||
* public static class IntegrationTestsConfig { ... } | ||
* | ||
* @RunWith(SpringJUnit4ClassRunner.class) | ||
* @ContextConfiguration(classes = IntegrationTestsConfig.class) | ||
* public static class IntegrationTests { | ||
* @Test | ||
* public void test2() { ... } | ||
* } | ||
* } | ||
* </pre> | ||
*/ | ||
public class ParallelInnerTestClassesSuite extends InnerTestClassesSuite { | ||
public ParallelInnerTestClassesSuite(Class<?> klass, RunnerBuilder runnerBuilder) throws InitializationError { | ||
super(klass, runnerBuilder); | ||
setScheduler(new ParallelScheduler()); | ||
} | ||
} |