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 a VariationSet 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 with FEATURE_TWO being inactive. In both runs FEATURE_ONE is enabled.

Author:
Christian Kaltepoth
  • Nested Class Summary

    Nested classes/interfaces inherited from class org.junit.runners.Suite

    org.junit.runners.Suite.SuiteClasses
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected List<org.junit.runner.Runner>
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected List<org.junit.runner.Runner>
     

    Methods inherited from class org.junit.runners.Suite

    describeChild, emptySuite, runChild

    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

    Methods inherited from class org.junit.runner.Runner

    testCount

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • runners

      protected List<org.junit.runner.Runner> runners
  • Constructor Details

    • FeatureVariations

      public FeatureVariations(Class<?> clazz) throws org.junit.runners.model.InitializationError
      Throws:
      org.junit.runners.model.InitializationError
  • Method Details

    • getChildren

      protected List<org.junit.runner.Runner> getChildren()
      Overrides:
      getChildren in class org.junit.runners.Suite