use of org.junit.runner.notification.RunListener in project junit4 by junit-team.
the class ListenerTest method notifyListenersInTheOrderInWhichTheyAreAdded.
@Test
public void notifyListenersInTheOrderInWhichTheyAreAdded() {
JUnitCore core = new JUnitCore();
log = "";
core.addListener(new RunListener() {
@Override
public void testRunStarted(Description description) throws Exception {
log += "first ";
}
});
core.addListener(new RunListener() {
@Override
public void testRunStarted(Description description) throws Exception {
log += "second ";
}
});
core.run(OneTest.class);
assertEquals("first second ", log);
}
use of org.junit.runner.notification.RunListener in project junit4 by junit-team.
the class BlockJUnit4ClassRunnerTest method methodBlockAfterFireTestStarted.
@Test
public void methodBlockAfterFireTestStarted() {
log = "";
JUnitCore junit = new JUnitCore();
junit.addListener(new RunListener() {
@Override
public void testStarted(Description description) throws Exception {
log += " testStarted(" + description.getMethodName() + ")";
}
@Override
public void testFinished(Description description) throws Exception {
log += " testFinished(" + description.getMethodName() + ")";
}
});
junit.run(MethodBlockAfterFireTestStarted.class);
assertEquals(" testStarted(test) init test testFinished(test)", log);
}
use of org.junit.runner.notification.RunListener in project junit4 by junit-team.
the class JUnitCore method runMain.
/**
* @param system system to run with
* @param args from main()
*/
Result runMain(JUnitSystem system, String... args) {
system.out().println("JUnit version " + Version.id());
JUnitCommandLineParseResult jUnitCommandLineParseResult = JUnitCommandLineParseResult.parse(args);
RunListener listener = new TextListener(system);
addListener(listener);
return run(jUnitCommandLineParseResult.createRequest(defaultComputer()));
}
use of org.junit.runner.notification.RunListener in project drools-wb by kiegroup.
the class JunitRunnerHelper method runWithJunit.
public static Result runWithJunit(Path path, Runner runner, List<Failure> failures, List<Failure> failureDetails) {
JUnitCore jUnitCore = new JUnitCore();
jUnitCore.addListener(new RunListener() {
@Override
public void testAssumptionFailure(org.junit.runner.notification.Failure failure) {
failureDetails.add(failureToFailure(path, failure));
}
});
Result result = jUnitCore.run(runner);
failures.addAll(failuresToFailures(path, result.getFailures()));
return result;
}
use of org.junit.runner.notification.RunListener in project bazel by bazelbuild.
the class JUnit4RunnerTest method getExpectedOutput.
private ByteArrayOutputStream getExpectedOutput(Class<?> testClass) {
JUnitCore core = new JUnitCore();
ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
PrintStream printStream = new PrintStream(byteStream);
printStream.println("JUnit4 Test Runner");
RunListener listener = new TextListener(printStream);
core.addListener(listener);
Request request = Request.classWithoutSuiteMethod(testClass);
core.run(request);
printStream.close();
return byteStream;
}
Aggregations