junitparams
Class ParameterisedTestClassRunner

java.lang.Object
  extended by junitparams.ParameterisedTestClassRunner

public class ParameterisedTestClassRunner
extends Object

Testclass-level functionalities to handle parameters from a JUnit runner class.

Author:
Pawel Lipinski

Field Summary
protected  Map<TestMethod,ParameterisedTestMethodRunner> parameterisedMethods
           
protected  Map<org.junit.runners.model.FrameworkMethod,TestMethod> testMethods
           
protected  List<TestMethod> testMethodsList
           
 
Constructor Summary
ParameterisedTestClassRunner(org.junit.runners.model.TestClass testClass)
          Creates a runner for a given test class.
 
Method Summary
 List<org.junit.runners.model.FrameworkMethod> computeFrameworkMethods(boolean firstTimeJustToGetNames)
          Returns a list of FrameworkMethods.
protected  void computeTestMethods(org.junit.runners.model.TestClass testClass)
           
 org.junit.runner.Description describeParameterisedMethod(org.junit.runners.model.FrameworkMethod method)
          Returns description of a parameterised method.
 org.junit.runners.model.Statement parameterisedMethodInvoker(org.junit.runners.model.FrameworkMethod method, Object testClass)
          Returns a InvokeParameterisedMethod for parameterised methods and null for nonparameterised
 void runParameterisedTest(TestMethod method, org.junit.runners.model.Statement methodInvoker, org.junit.runner.notification.RunNotifier notifier)
          Executes parameterised method.
 boolean shouldRun(TestMethod testMethod)
          Tells if method should be run by this runner.
 TestMethod testMethodFor(org.junit.runners.model.FrameworkMethod method)
          Returns a cached TestMethod object related to the given FrameworkMethod.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

parameterisedMethods

protected Map<TestMethod,ParameterisedTestMethodRunner> parameterisedMethods

testMethods

protected Map<org.junit.runners.model.FrameworkMethod,TestMethod> testMethods

testMethodsList

protected List<TestMethod> testMethodsList
Constructor Detail

ParameterisedTestClassRunner

public ParameterisedTestClassRunner(org.junit.runners.model.TestClass testClass)
Creates a runner for a given test class. Computes all the test methods that are annotated as tests. Retrieves and caches all parameter values.

Parameters:
testClass -
Method Detail

computeTestMethods

protected void computeTestMethods(org.junit.runners.model.TestClass testClass)

computeFrameworkMethods

public List<org.junit.runners.model.FrameworkMethod> computeFrameworkMethods(boolean firstTimeJustToGetNames)
Returns a list of FrameworkMethods. Handles both parameterised methods (counts them as many times as many paramsets they have) and nonparameterised methods (just counts them once).

Parameters:
firstTimeJustToGetNames - If true, returns only parameterised methods once - used by JUnit for building the tree of test names without the params.
Returns:
a list of FrameworkMethod objects

parameterisedMethodInvoker

public org.junit.runners.model.Statement parameterisedMethodInvoker(org.junit.runners.model.FrameworkMethod method,
                                                                    Object testClass)
Returns a InvokeParameterisedMethod for parameterised methods and null for nonparameterised

Parameters:
method - Test method
testClass -
Returns:
a Statement with the invoker for the parameterised method

shouldRun

public boolean shouldRun(TestMethod testMethod)
Tells if method should be run by this runner.

Parameters:
testMethod -
Returns:
true, iff testMethod should be run by this runner.

runParameterisedTest

public void runParameterisedTest(TestMethod method,
                                 org.junit.runners.model.Statement methodInvoker,
                                 org.junit.runner.notification.RunNotifier notifier)
Executes parameterised method.

Parameters:
method -
methodInvoker -
notifier -

describeParameterisedMethod

public org.junit.runner.Description describeParameterisedMethod(org.junit.runners.model.FrameworkMethod method)
Returns description of a parameterised method.

Parameters:
method - TODO
Returns:
Description of a method or null if it's not parameterised.

testMethodFor

public TestMethod testMethodFor(org.junit.runners.model.FrameworkMethod method)
Returns a cached TestMethod object related to the given FrameworkMethod. This object has all the params already retrieved, so use this one and not TestMethod's constructor if you want to have everything retrieved once and cached.

Parameters:
method -
Returns:
a cached TestMethod instance


Copyright © 2012 Pragmatists. All Rights Reserved.