bb.util
Class JUnitExecutor.TestRunEvents
java.lang.Object
org.junit.runner.notification.RunListener
bb.util.JUnitExecutor.RunListenerAbstract
bb.util.JUnitExecutor.TestRunEvents
- Enclosing class:
- JUnitExecutor
private static class JUnitExecutor.TestRunEvents
- extends JUnitExecutor.RunListenerAbstract
Stores all events which occur during a test run, from which it can generate a report.
This class is multithread safe: every method is synchronized.
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
events
private String events
timeRunStartNs
private long timeRunStartNs
timeTestStartNs
private long timeTestStartNs
ignored
private boolean ignored
failure
private Failure failure
classToMethodsFailed
private final SortedMap<String,SortedSet<String>> classToMethodsFailed
JUnitExecutor.TestRunEvents
private JUnitExecutor.TestRunEvents()
testRunStarted
public void testRunStarted(Description description)
- Overrides:
testRunStarted
in class RunListener
testStarted
public void testStarted(Description description)
- Overrides:
testStarted
in class RunListener
testIgnored
public void testIgnored(Description description)
- Note: the Junit 4 javadocs do not describe this method well (as of 2008/5/8),
but it currently is called instead of
testStarted
if the method is annotated with both @Ignore and @Test.
In this case, there will be no subsequent call to testFinished
;
only this method is called.
- Overrides:
testIgnored
in class RunListener
testFailure
public void testFailure(Failure failure)
- Called in between calls to
testStarted
and testFinished
if a test method fails.
- Overrides:
testFailure
in class RunListener
testFinished
public void testFinished(Description description)
- Overrides:
testFinished
in class RunListener
testRunFinished
public void testRunFinished(Result result)
- Overrides:
testRunFinished
in class RunListener
getEvents
private String getEvents()
throws IllegalStateException
- Returns a summary of all the events that have been recorded since the last call of
testRunStarted
.
May be called while in the middle of a run to get all the events that have happened so far,
or after a run has finished to get a report of all the events.
The result is never null or empty.
A typical result (once a run has finished) looks like:
JUnit 4 run started for: All
--------------------------------------------------
somepackage.SomeClass$UnitTest
test_method1: PASSED; execution time = 1 ms
test_method2: IGNORED; execution time = 2 us
test_method3: FAILED: java.lang.RuntimeException: unexpected error happened; execution time = 3 ms
--------------------------------------------------
anotherpackage.AnotherClass$UnitTest
test_methodA: PASSED; execution time = 4 ms
test_methodB: IGNORED; execution time = 5 us
test_methodC: FAILED: java.lang.RuntimeException: unexpected error happened; execution time = 6 ms
--------------------------------------------------
JUnit 4 run FAILED: 2/4 tests failed (2 tests were ignored); total execution time = 100 ms
Note: there are 4 test output files inside ..\log\testOutput
- Throws:
IllegalStateException
- if testRunStarted has never been called