Class SplitTestRunner

java.lang.Object
org.junit.runner.Runner
org.junit.runners.ParentRunner<org.junit.runners.model.FrameworkMethod>
org.junit.runners.BlockJUnit4ClassRunner
io.split.client.testing.runner.SplitTestRunner
All Implemented Interfaces:
org.junit.runner.Describable, org.junit.runner.manipulation.Filterable, org.junit.runner.manipulation.Sortable

public class SplitTestRunner
extends org.junit.runners.BlockJUnit4ClassRunner
Split Test Runner

Extension of standard JUnit 4 Runner Leverages Split* Testing Annotations to automate unit testing across various Feature Flag treatments Only one Annotation is respected per Test (IE Can not combine @SplitTest with @SplitScenarios on a single Test method)

  • Constructor Summary

    Constructors 
    Constructor Description
    SplitTestRunner​(Class<?> klass)
    Split Test Runner Constructor
  • Method Summary

    Modifier and Type Method Description
    protected List<org.junit.runners.model.FrameworkMethod> computeTestMethods()
    Run tests in Alphabetical Order
    protected org.junit.runner.Description describeChild​(org.junit.runners.model.FrameworkMethod method)
    Generate Test Description
    Suite generateSuite​(org.junit.runners.model.FrameworkMethod method)  
    protected void runChild​(org.junit.runners.model.FrameworkMethod method, org.junit.runner.notification.RunNotifier notifier)
    Run Suite of Scenarios for a Test
    protected org.junit.runners.model.Statement withBefores​(org.junit.runners.model.FrameworkMethod method, Object target, org.junit.runners.model.Statement statement)
    Adds Split Application to the Test's Call Stack

    Methods inherited from class org.junit.runners.BlockJUnit4ClassRunner

    collectInitializationErrors, createTest, getChildren, getTestRules, isIgnored, methodBlock, methodInvoker, possiblyExpectingExceptions, rules, testName, validateConstructor, validateFields, validateInstanceMethods, validateNoNonStaticInnerClass, validateOnlyOneConstructor, validateTestMethods, validateZeroArgConstructor, withAfters, withPotentialTimeout

    Methods inherited from class org.junit.runners.ParentRunner

    childrenInvoker, classBlock, classRules, createTestClass, filter, getDescription, getName, getRunnerAnnotations, getTestClass, run, runLeaf, setScheduler, sort, validatePublicVoidNoArgMethods, withAfterClasses, withBeforeClasses

    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
  • Constructor Details

    • SplitTestRunner

      public SplitTestRunner​(Class<?> klass) throws org.junit.runners.model.InitializationError
      Split Test Runner Constructor

      Runner is instantiated by using the @RunWith(SplitTestRunner.class) annotation. Not to be called directly.

      Parameters:
      klass - The Test class to be run
      Throws:
      org.junit.runners.model.InitializationError - Error occurred during class initialization
  • Method Details

    • computeTestMethods

      protected List<org.junit.runners.model.FrameworkMethod> computeTestMethods()
      Run tests in Alphabetical Order

      Runner is instantiated by using the @RunWith(SplitTestRunner.class) annotation. Not to be called directly.

      Overrides:
      computeTestMethods in class org.junit.runners.BlockJUnit4ClassRunner
    • runChild

      protected void runChild​(org.junit.runners.model.FrameworkMethod method, org.junit.runner.notification.RunNotifier notifier)
      Run Suite of Scenarios for a Test

      Generates a Suite of Scenarios and then runs the test once for each permutation. If no Scenarios are defined, or the only defined Scenario has no Tests set, Run test normally

      Overrides:
      runChild in class org.junit.runners.BlockJUnit4ClassRunner
      Parameters:
      method - The Test function to be run
      notifier - The notifier class tracking test execution
    • withBefores

      protected org.junit.runners.model.Statement withBefores​(org.junit.runners.model.FrameworkMethod method, Object target, org.junit.runners.model.Statement statement)
      Adds Split Application to the Test's Call Stack

      This Override method first adds the application of Splits to run before the test execution. Then calls the SuperClass's method to add all @Before annotations to the call stack

      This is required to ensure the Tested code is using the same SplitClient that the Runner is using.

      Overrides:
      withBefores in class org.junit.runners.BlockJUnit4ClassRunner
      Returns:
      An instance of the Test Class being run
    • generateSuite

      public Suite generateSuite​(org.junit.runners.model.FrameworkMethod method)
    • describeChild

      protected org.junit.runner.Description describeChild​(org.junit.runners.model.FrameworkMethod method)
      Generate Test Description

      If no Scenarios are on for that test, describe normally Otherwise Describe as a Suite of tests, showing the active splits for each Scenario in that run's description

      Overrides:
      describeChild in class org.junit.runners.BlockJUnit4ClassRunner
      Parameters:
      method - The Test method to be run
      Returns:
      A formatted description of that Test