Class TestParameterInjector

java.lang.Object
org.junit.runner.Runner
org.junit.runners.ParentRunner<org.junit.runners.model.FrameworkMethod>
org.junit.runners.BlockJUnit4ClassRunner
com.google.testing.junit.testparameterinjector.TestParameterInjector
All Implemented Interfaces:
org.junit.runner.Describable, org.junit.runner.manipulation.Filterable, org.junit.runner.manipulation.Orderable, org.junit.runner.manipulation.Sortable

public final class TestParameterInjector
extends org.junit.runners.BlockJUnit4ClassRunner
A JUnit test runner which knows how to instantiate and run test classes where each test case may be parameterized with its own unique set of test parameters (as opposed to Parameterized where each test case in a test class is invoked with the exact same set of parameters).
  • Constructor Summary

    Constructors 
    Constructor Description
    TestParameterInjector​(Class<?> testClass)  
  • Method Summary

    Modifier and Type Method Description
    protected void collectInitializationErrors​(List<Throwable> errors)  
    protected com.google.common.collect.ImmutableList<org.junit.runners.model.FrameworkMethod> computeTestMethods()  
    protected Object createTest()  
    protected List<com.google.testing.junit.testparameterinjector.TestMethodProcessor> createTestMethodProcessorList()
    Returns the list of TestMethodProcessors to use.
    protected void finalizeCreatedTestInstance​(Object testInstance)
    This method is run to perform optional additional operations on the test instance, right after it was created.
    protected List<org.junit.rules.MethodRule> getInnerMethodRules()
    MethodRules that will be executed after the ones defined in the test class.
    protected List<org.junit.rules.TestRule> getInnerTestRules()
    TestRules that will be executed after the ones defined in the test class (but still before all MethodRules).
    protected List<org.junit.rules.MethodRule> getOuterMethodRules()
    MethodRules that will be executed before the ones defined in the test class (but still after all TestRules).
    protected List<org.junit.rules.TestRule> getOuterTestRules()
    TestRules that will be executed before the ones defined in the test class.
    protected org.junit.runners.model.Statement methodBlock​(org.junit.runners.model.FrameworkMethod method)  
    protected org.junit.runners.model.Statement methodInvoker​(org.junit.runners.model.FrameworkMethod frameworkMethod, Object testObject)  
    static com.google.common.collect.ImmutableList<org.junit.runner.notification.Failure> run​(com.google.testing.junit.testparameterinjector.PluggableTestRunner testRunner)
    Runs a testClass with the PluggableTestRunner, and returns a list of test Failure, or an empty list if no failure occurred.
    protected boolean shouldSortTestMethodsDeterministically()
    If true, all test methods (across different TestMethodProcessors) will be sorted in a deterministic way by their test name.
    protected void validatePublicVoidNoArgMethods​(Class<? extends Annotation> annotation, boolean isStatic, List<Throwable> errors)  
    protected void validateTestMethods​(List<Throwable> list)  
    protected void validateZeroArgConstructor​(List<Throwable> errorsReturned)  

    Methods inherited from class org.junit.runners.BlockJUnit4ClassRunner

    createTest, describeChild, getChildren, getTestRules, isIgnored, possiblyExpectingExceptions, rules, runChild, testName, validateConstructor, validateFields, validateInstanceMethods, validateNoNonStaticInnerClass, validateOnlyOneConstructor, withAfters, withBefores, withPotentialTimeout

    Methods inherited from class org.junit.runners.ParentRunner

    childrenInvoker, classBlock, classRules, createTestClass, filter, getDescription, getName, getRunnerAnnotations, getTestClass, order, run, runLeaf, setScheduler, sort, 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
  • Constructor Details

    • TestParameterInjector

      public TestParameterInjector​(Class<?> testClass) throws org.junit.runners.model.InitializationError
      Throws:
      org.junit.runners.model.InitializationError
  • Method Details

    • createTestMethodProcessorList

      protected List<com.google.testing.junit.testparameterinjector.TestMethodProcessor> createTestMethodProcessorList()
      Returns the list of TestMethodProcessors to use. This is meant to be overridden by subclasses.
    • finalizeCreatedTestInstance

      protected void finalizeCreatedTestInstance​(Object testInstance)
      This method is run to perform optional additional operations on the test instance, right after it was created.
    • shouldSortTestMethodsDeterministically

      protected boolean shouldSortTestMethodsDeterministically()
      If true, all test methods (across different TestMethodProcessors) will be sorted in a deterministic way by their test name.

      Deterministic means that the order will not change, even when tests are added/removed or between releases.

    • getInnerTestRules

      protected List<org.junit.rules.TestRule> getInnerTestRules()
      TestRules that will be executed after the ones defined in the test class (but still before all MethodRules). This is meant to be overridden by subclasses.
    • getOuterTestRules

      protected List<org.junit.rules.TestRule> getOuterTestRules()
      TestRules that will be executed before the ones defined in the test class. This is meant to be overridden by subclasses.
    • getInnerMethodRules

      protected List<org.junit.rules.MethodRule> getInnerMethodRules()
      MethodRules that will be executed after the ones defined in the test class. This is meant to be overridden by subclasses.
    • getOuterMethodRules

      protected List<org.junit.rules.MethodRule> getOuterMethodRules()
      MethodRules that will be executed before the ones defined in the test class (but still after all TestRules). This is meant to be overridden by subclasses.
    • run

      public static com.google.common.collect.ImmutableList<org.junit.runner.notification.Failure> run​(com.google.testing.junit.testparameterinjector.PluggableTestRunner testRunner) throws Exception
      Runs a testClass with the PluggableTestRunner, and returns a list of test Failure, or an empty list if no failure occurred.
      Throws:
      Exception
    • computeTestMethods

      protected final com.google.common.collect.ImmutableList<org.junit.runners.model.FrameworkMethod> computeTestMethods()
      Overrides:
      computeTestMethods in class org.junit.runners.BlockJUnit4ClassRunner
    • methodBlock

      protected final org.junit.runners.model.Statement methodBlock​(org.junit.runners.model.FrameworkMethod method)
      Overrides:
      methodBlock in class org.junit.runners.BlockJUnit4ClassRunner
    • methodInvoker

      protected final org.junit.runners.model.Statement methodInvoker​(org.junit.runners.model.FrameworkMethod frameworkMethod, Object testObject)
      Overrides:
      methodInvoker in class org.junit.runners.BlockJUnit4ClassRunner
    • validateZeroArgConstructor

      protected final void validateZeroArgConstructor​(List<Throwable> errorsReturned)
      Overrides:
      validateZeroArgConstructor in class org.junit.runners.BlockJUnit4ClassRunner
    • validateTestMethods

      protected final void validateTestMethods​(List<Throwable> list)
      Overrides:
      validateTestMethods in class org.junit.runners.BlockJUnit4ClassRunner
    • collectInitializationErrors

      protected final void collectInitializationErrors​(List<Throwable> errors)
      Overrides:
      collectInitializationErrors in class org.junit.runners.BlockJUnit4ClassRunner
    • createTest

      protected final Object createTest() throws Exception
      Overrides:
      createTest in class org.junit.runners.BlockJUnit4ClassRunner
      Throws:
      Exception
    • validatePublicVoidNoArgMethods

      protected final void validatePublicVoidNoArgMethods​(Class<? extends Annotation> annotation, boolean isStatic, List<Throwable> errors)
      Overrides:
      validatePublicVoidNoArgMethods in class org.junit.runners.ParentRunner<org.junit.runners.model.FrameworkMethod>