Junit Toolbox
April 30, 2018
I wanted a way to easily run a subset of my unit tests. We already had categories on each test, and it is possible to limit which tests are run using junit-toolbox, details at https://github.com/MichaelTamm/junit-toolbox
For each test we have one or more categories defined. Each category is a simple Java interface.
@Category(IMyCategory.class, ISmokeTestCategory.class) @Test public void testMethod(){ /// blah }
To run all tests except those marked with IElkCategory
:
@RunWith(WildcardPatternSuite.class) @SuiteClasses("**/*Tests.class") @ExcludeCategories(IElkCategory.class) public class RunAllNoElk { }
Running this class as a JUnit test kicks off the appropriate test set.
Its also possible to limit the run to only specific categories:
@RunWith(WildcardPatternSuite.class) @SuiteClasses("**/*Tests.class") @ExcludeCategories(IElkCategory.class) @IncludeCategories(ISmokeTestCategory.class) public class RunSmokeTest { }