Class TogglzRule

java.lang.Object
org.togglz.junit.TogglzRule
All Implemented Interfaces:
org.junit.rules.TestRule

public class TogglzRule extends Object implements org.junit.rules.TestRule

JUnit rule that simplifies the process of controlling features in unit tests.

Example usage:

 public class TogglzRuleAllEnabledTest {

   @Rule
   public TogglzRule togglzRule = TogglzRule.allEnabled(MyFeatures.class);

   @Test
   public void testToggleFeature() {

     assertTrue(MyFeatures.FEATURE_ONE.isActive());

     togglzRule.disable(MyFeatures.FEATURE_ONE);

     assertFalse(MyFeatures.FEATURE_ONE.isActive());

   }

 }
 
Author:
Christian Kaltepoth
  • Method Details

    • builder

      public static TogglzRule.Builder builder(Class<? extends org.togglz.core.Feature> featuresClass)
    • allEnabled

      public static TogglzRule allEnabled(Class<? extends org.togglz.core.Feature> featureClass)
    • allDisabled

      public static TogglzRule allDisabled(Class<? extends org.togglz.core.Feature> featureClass)
    • apply

      public org.junit.runners.model.Statement apply(org.junit.runners.model.Statement base, org.junit.runner.Description description)
      Specified by:
      apply in interface org.junit.rules.TestRule
    • disable

      public void disable(org.togglz.core.Feature feature)
    • enable

      public void enable(org.togglz.core.Feature feature)