bb.util
Class JUnitExecutor.StdStreamSwapper
java.lang.Object
org.junit.runner.notification.RunListener
bb.util.JUnitExecutor.RunListenerAbstract
bb.util.JUnitExecutor.StdStreamSwapper
- Enclosing class:
- JUnitExecutor
private static class JUnitExecutor.StdStreamSwapper
- extends JUnitExecutor.RunListenerAbstract
Every time that a test method is about to be executed,
this intercepts the standard streams (out and err) and captures any output.
The last line of each stream's output is continously overwritten to the console
to let the user know what the test method is generating.
Each stream's complete output is saved to a dedicated file once the test method finishes.
This both reduces the console clutter
as well as makes it extremely easy to find the output from a given test method.
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 |
classDir
private File classDir
fileOut
private File fileOut
fileErr
private File fileErr
JUnitExecutor.StdStreamSwapper
private JUnitExecutor.StdStreamSwapper()
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)
- 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
onProblem
private void onProblem(String message,
Throwable t)
throws RuntimeException
- Handles problems generated by the JUnit framework itself (including this class),
as opposed to Throwables raised by the test methods
(which should get caught by the JUnit framework and passed to
testFailure
).
This method simply calls StdStreams.unswap
and then throws a new RuntimeException made from message and t.
- Throws:
RuntimeException