org.ops4j.pax.exam.junit
Class JUnit4TestRunner

java.lang.Object
  extended by org.junit.runner.Runner
      extended by org.ops4j.pax.exam.junit.JUnit4TestRunner
All Implemented Interfaces:
org.junit.runner.manipulation.Filterable, org.junit.runner.manipulation.Sortable
Direct Known Subclasses:
AbstractJUnit4TestRunner

public class JUnit4TestRunner
extends org.junit.runner.Runner
implements org.junit.runner.manipulation.Filterable, org.junit.runner.manipulation.Sortable

JUnit4 Runner to be used with the RunWith annotation to run with Pax Exam. The class is basically a copy of JUnit4ClassRunner addapted to Pax Exam, keeping as much as possible the original implementation. It was not possible to just extend and override the JUnit4ClassRunner due to internal list fTestMethods that is a list of Methods, and we have to keep extra info about the test methods and Method is a final class.

Since:
0.3.0, December 16, 2008
Author:
Alin Dreghiciu (adreghiciu@gmail.com)

Constructor Summary
JUnit4TestRunner(java.lang.Class<?> klass)
           
 
Method Summary
protected  java.lang.annotation.Annotation[] classAnnotations()
           
protected  java.lang.Object createTest()
           
 void filter(org.junit.runner.manipulation.Filter filter)
           
protected  java.util.Collection<JUnit4ConfigMethod> getConfigurationMethods()
          Finds the configuration methods based on the configured ConfigurationStrategy.
 org.junit.runner.Description getDescription()
           
protected  java.lang.String getName()
           
protected  org.junit.internal.runners.TestClass getTestClass()
           
protected  java.util.List<JUnit4TestMethod> getTestMethods()
           
protected  void invokeTestMethod(JUnit4TestMethod method, org.junit.runner.notification.RunNotifier notifier)
           
protected  org.junit.runner.Description methodDescription(JUnit4TestMethod method)
           
protected  org.junit.runner.Description methodDescription(java.lang.reflect.Method method)
           
 void run(org.junit.runner.notification.RunNotifier notifier)
           
protected  void runMethods(org.junit.runner.notification.RunNotifier notifier)
           
 void sort(org.junit.runner.manipulation.Sorter sorter)
           
protected  java.lang.annotation.Annotation[] testAnnotations(java.lang.reflect.Method method)
           
protected  java.lang.String testName(JUnit4TestMethod method)
           
protected  java.lang.String testName(java.lang.reflect.Method method)
           
protected  void validate()
           
protected  org.junit.internal.runners.TestMethod wrapMethod(java.lang.reflect.Method method)
           
 
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 Detail

JUnit4TestRunner

public JUnit4TestRunner(java.lang.Class<?> klass)
                 throws org.junit.internal.runners.InitializationError
Throws:
org.junit.internal.runners.InitializationError
Method Detail

getTestMethods

protected java.util.List<JUnit4TestMethod> getTestMethods()
                                                   throws java.lang.Exception
Throws:
java.lang.Exception

getConfigurationMethods

protected java.util.Collection<JUnit4ConfigMethod> getConfigurationMethods()
                                                                    throws java.lang.Exception
Finds the configuration methods based on the configured ConfigurationStrategy.

Returns:
collection of configuration methods (cannot be null but can be empty)
Throws:
java.lang.Exception - - If test instance cannot be created - Re-thrown while finding the configuration methods

validate

protected void validate()
                 throws org.junit.internal.runners.InitializationError
Throws:
org.junit.internal.runners.InitializationError

run

public void run(org.junit.runner.notification.RunNotifier notifier)
Specified by:
run in class org.junit.runner.Runner

runMethods

protected void runMethods(org.junit.runner.notification.RunNotifier notifier)

getDescription

public org.junit.runner.Description getDescription()
Specified by:
getDescription in class org.junit.runner.Runner

classAnnotations

protected java.lang.annotation.Annotation[] classAnnotations()

getName

protected java.lang.String getName()

createTest

protected java.lang.Object createTest()
                               throws java.lang.Exception
Throws:
java.lang.Exception

invokeTestMethod

protected void invokeTestMethod(JUnit4TestMethod method,
                                org.junit.runner.notification.RunNotifier notifier)

wrapMethod

protected org.junit.internal.runners.TestMethod wrapMethod(java.lang.reflect.Method method)

testName

protected java.lang.String testName(java.lang.reflect.Method method)

testName

protected java.lang.String testName(JUnit4TestMethod method)

methodDescription

protected org.junit.runner.Description methodDescription(java.lang.reflect.Method method)

methodDescription

protected org.junit.runner.Description methodDescription(JUnit4TestMethod method)

testAnnotations

protected java.lang.annotation.Annotation[] testAnnotations(java.lang.reflect.Method method)

filter

public void filter(org.junit.runner.manipulation.Filter filter)
            throws org.junit.runner.manipulation.NoTestsRemainException
Specified by:
filter in interface org.junit.runner.manipulation.Filterable
Throws:
org.junit.runner.manipulation.NoTestsRemainException

sort

public void sort(org.junit.runner.manipulation.Sorter sorter)
Specified by:
sort in interface org.junit.runner.manipulation.Sortable

getTestClass

protected org.junit.internal.runners.TestClass getTestClass()


Copyright © 2006-2012 OPS4J - Open Participation Software for Java. All Rights Reserved.