patterntesting.runtime.junit
Class SmokeRunner

Package class diagram package SmokeRunner
java.lang.Object
  extended by org.junit.runner.Runner
      extended by org.junit.runners.ParentRunner<org.junit.runners.model.FrameworkMethod>
          extended by patterntesting.runtime.junit.SmokeRunner
All Implemented Interfaces:
org.junit.runner.Describable, org.junit.runner.manipulation.Filterable, org.junit.runner.manipulation.Sortable
Direct Known Subclasses:
ProxyRunner

public class SmokeRunner
extends org.junit.runners.ParentRunner<org.junit.runners.model.FrameworkMethod>

This is the eXtended Runner for JUnit 4 which handles the SmokeTest and other annotations. In previous (intermediate) version it was called "XRunner". But because this may be a little bit confusing name it was renamed to "SmokeRunner" for the final version.
It can be used together with the @RunWith annotation of JUnit 4.

Since:
1.0 (29.03.2010)
Author:
oliver

Constructor Summary
SmokeRunner(Class<?> klass)
          Creates a SmokeRunner to run klass methods in parallel.
 
Method Summary
protected  void addFailure(org.junit.runner.notification.RunNotifier notifier, Throwable targetException, org.junit.runner.Description description)
          This method was inspired from an internal JUnit class (EachTestNotifier#addFailure(Throwable)).
protected  org.junit.runner.Description describeChild(org.junit.runners.model.FrameworkMethod child)
          Create a Description of a single test named name in the class clazz.
protected static void fireTestAssumptionFailed(org.junit.runner.notification.RunNotifier notifier, org.junit.runner.Description description, Exception ex)
          In JUnit 4.5 and newer we can use the fireTestAssumptionFailed(..)
protected  List<org.junit.runners.model.FrameworkMethod> getChildren()
          Returns the methods that run tests.
protected  SmokeFilter getFilter()
          The ParentRunner allows us no access to the filter.
static List<org.junit.runners.model.FrameworkMethod> getJUnit3TestMethods(Class<?> testClass)
          Here we look after public void methods with "test" as prefix and with no arguments.
protected  void logStatement(org.junit.runners.model.Statement stmt)
          We will give a subclass (like e.g.
protected  org.junit.runners.model.Statement methodBlock(org.junit.runners.model.FrameworkMethod method)
          Creates a RunStatement for the given test method.
protected  void runChild(org.junit.runners.model.FrameworkMethod method, org.junit.runner.notification.RunNotifier notifier)
          Runs the test corresponding to child, which can be assumed to be an element of the list returned by ParentRunner.getChildren().
protected  boolean shouldBeIgnored(org.junit.runners.model.FrameworkMethod method)
          Here we handle annotations like @Ignore where the execution of the test method should be ignored.
protected  boolean shouldBeRun(org.junit.runners.model.FrameworkMethod method)
          Should be run.
protected  org.junit.runners.model.Statement withAfterClasses(org.junit.runners.model.Statement statement)
          Checks the annotation of the method marked as "@AfterClass" and add (or filters out) the afterClass method (needed to solve.
protected  org.junit.runners.model.Statement withBeforeClasses(org.junit.runners.model.Statement statement)
          Checks the annotation of the method marked as "@BeforeClass" and add (or filters out) the beforeClass method (needed to solve.
 
Methods inherited from class org.junit.runners.ParentRunner
childrenInvoker, classBlock, classRules, collectInitializationErrors, filter, getDescription, getName, getRunnerAnnotations, getTestClass, run, runLeaf, setScheduler, sort, validatePublicVoidNoArgMethods
 
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

SmokeRunner

public SmokeRunner(Class<?> klass)
            throws org.junit.runners.model.InitializationError
Creates a SmokeRunner to run klass methods in parallel.

Parameters:
klass - the test class to run
Throws:
org.junit.runners.model.InitializationError - if the test class is malformed
Method Detail

getFilter

protected final SmokeFilter getFilter()
The ParentRunner allows us no access to the filter. So we added this method here (e.g. needed by the ParallelRunner).

Returns:
the SmokeFilter

getChildren

protected List<org.junit.runners.model.FrameworkMethod> getChildren()
Returns the methods that run tests. Default implementation returns all methods annotated with @Test on this class and superclasses that are not overridden.

Specified by:
getChildren in class org.junit.runners.ParentRunner<org.junit.runners.model.FrameworkMethod>
Returns:
the methods that run tests

describeChild

protected org.junit.runner.Description describeChild(org.junit.runners.model.FrameworkMethod child)
Create a Description of a single test named name in the class clazz. Generally, this will be a leaf Description. (see also BlockJUnit4ClassRunner)

Specified by:
describeChild in class org.junit.runners.ParentRunner<org.junit.runners.model.FrameworkMethod>
Parameters:
child - the name of the test (a method name for test annotated with Test)
Returns:
the description
See Also:
ParentRunner.describeChild(java.lang.Object)

withBeforeClasses

protected org.junit.runners.model.Statement withBeforeClasses(org.junit.runners.model.Statement statement)
Checks the annotation of the method marked as "@BeforeClass" and add (or filters out) the beforeClass method (needed to solve.

Overrides:
withBeforeClasses in class org.junit.runners.ParentRunner<org.junit.runners.model.FrameworkMethod>
Parameters:
statement - the statement(s) before
Returns:
the statement(s) after with the BeforeClass method "https://sourceforge.net/tracker/?func=detail&aid=3034823&group_id=48833&atid=454317").
See Also:
ParentRunner.withBeforeClasses(org.junit.runners.model.Statement)

withAfterClasses

protected org.junit.runners.model.Statement withAfterClasses(org.junit.runners.model.Statement statement)
Checks the annotation of the method marked as "@AfterClass" and add (or filters out) the afterClass method (needed to solve.

Overrides:
withAfterClasses in class org.junit.runners.ParentRunner<org.junit.runners.model.FrameworkMethod>
Parameters:
statement - the statement(s) before
Returns:
the statement(s) after with the AfterClass method "https://sourceforge.net/tracker/?func=detail&aid=3034823&group_id=48833&atid=454317").
See Also:
ParentRunner.withAfterClasses(org.junit.runners.model.Statement)

runChild

protected void runChild(org.junit.runners.model.FrameworkMethod method,
                        org.junit.runner.notification.RunNotifier notifier)
Runs the test corresponding to child, which can be assumed to be an element of the list returned by ParentRunner.getChildren(). Subclasses are responsible for making sure that relevant test events are reported through notifier

Specified by:
runChild in class org.junit.runners.ParentRunner<org.junit.runners.model.FrameworkMethod>
Parameters:
method - the method
notifier - the notifier

fireTestAssumptionFailed

protected static void fireTestAssumptionFailed(org.junit.runner.notification.RunNotifier notifier,
                                               org.junit.runner.Description description,
                                               Exception ex)
In JUnit 4.5 and newer we can use the fireTestAssumptionFailed(..) of the RunNotifier class. But JUnit 4.4 does not provide this method.
We could map it to the RunNotifier.fireTestFailure(Failure) method - but this does not work for JUnit 4.5 (some internal JUnit tests will fail if you try that). We could compile with JUnit 4.5, run the tests with JUnit 4.4 and see what will happen. Perhaps we can catch the exception and call the RunNotifier.fireTestFailure(Failure) method. We could also give up because the architecture of JUnit has changed too much between 4.4 and 4.5 - this is, what we do now.

Parameters:
notifier - the notifier
description - the description
ex - the ex
Since:
1.2.20

logStatement

protected void logStatement(org.junit.runners.model.Statement stmt)
We will give a subclass (like e.g. ParallelRunner) the chance to report the statement with its own logger.

Parameters:
stmt - the stmt to be logged

shouldBeIgnored

protected final boolean shouldBeIgnored(org.junit.runners.model.FrameworkMethod method)
Here we handle annotations like @Ignore where the execution of the test method should be ignored.

Parameters:
method - the test method
Returns:
true or false

shouldBeRun

protected final boolean shouldBeRun(org.junit.runners.model.FrameworkMethod method)
Should be run.

Parameters:
method - the method
Returns:
true, if successful

addFailure

protected final void addFailure(org.junit.runner.notification.RunNotifier notifier,
                                Throwable targetException,
                                org.junit.runner.Description description)
This method was inspired from an internal JUnit class (EachTestNotifier#addFailure(Throwable)).

Parameters:
notifier - the notifier
targetException - the target exception
description - the description

methodBlock

protected org.junit.runners.model.Statement methodBlock(org.junit.runners.model.FrameworkMethod method)
Creates a RunStatement for the given test method.

Parameters:
method - the test method
Returns:
a created RunStatement

getJUnit3TestMethods

public static List<org.junit.runners.model.FrameworkMethod> getJUnit3TestMethods(Class<?> testClass)
Here we look after public void methods with "test" as prefix and with no arguments.
NOTE: This method is public because it is also needed by patterntesting.concurrent.junit.JUnit3Executor

Parameters:
testClass - the test class
Returns:
a list of public methods starting with prefix "test"


Copyright © 2002–2014 PatternTesting Team. All rights reserved.