Package org.togglz.junit.vary
Class FeatureVariations
- java.lang.Object
-
- org.junit.runner.Runner
-
- org.junit.runners.ParentRunner<org.junit.runner.Runner>
-
- org.junit.runners.Suite
-
- org.togglz.junit.vary.FeatureVariations
-
- All Implemented Interfaces:
org.junit.runner.Describable
,org.junit.runner.manipulation.Filterable
,org.junit.runner.manipulation.Orderable
,org.junit.runner.manipulation.Sortable
public class FeatureVariations extends org.junit.runners.Suite
This class is custom JUnit runner that allows to run tests against different feature combinations. A usecase for this runner would be for example to test feature toggles that enable caching behavior. The runner can be configured to run the tests two times. Once with the flag enabled and once with the flag being disabled.
Tests executed with this runner must implement a public static method annotated with
Variations
. This method must return aVariationSet
set specifies which features should be varied.Usage example:
@RunWith(FeatureVariations.class) public class FeatureVariationsTest { @Variations public static VariationSet<MyFeatures> getPermutations() { return VariationSetBuilder.create(MyFeatures.class) .enable(MyFeatures.FEATURE_ONE) .vary(MyFeatures.FEATURE_TWO); } @Test public void test() { // do the tests } }
In this example the test is executed two times. Once with
FEATURE_TWO
being active and once withFEATURE_TWO
being inactive. In both runsFEATURE_ONE
is enabled.- Author:
- Christian Kaltepoth
-
-
Constructor Summary
Constructors Constructor Description FeatureVariations(Class<?> clazz)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected List<org.junit.runner.Runner>
getChildren()
-
Methods inherited from class org.junit.runners.ParentRunner
childrenInvoker, classBlock, classRules, collectInitializationErrors, createTestClass, filter, getDescription, getName, getRunnerAnnotations, getTestClass, isIgnored, order, run, runLeaf, setScheduler, sort, validatePublicVoidNoArgMethods, withAfterClasses, withBeforeClasses, withInterruptIsolation
-
-
-
-
Field Detail
-
runners
protected List<org.junit.runner.Runner> runners
-
-
Constructor Detail
-
FeatureVariations
public FeatureVariations(Class<?> clazz) throws org.junit.runners.model.InitializationError
- Throws:
org.junit.runners.model.InitializationError
-
-
Method Detail
-
getChildren
protected List<org.junit.runner.Runner> getChildren()
- Overrides:
getChildren
in classorg.junit.runners.Suite
-
-