use of org.junit.runner.notification.RunNotifier in project junit4 by junit-team.
the class ErrorReportingRunnerTest method givenInvalidTestClassErrorAsCause.
@Test
public void givenInvalidTestClassErrorAsCause() {
final List<Failure> firedFailures = new ArrayList<Failure>();
InvalidTestClassError testClassError = new InvalidTestClassError(TestClassWithErrors.class, Arrays.asList(new Throwable("validation error 1"), new Throwable("validation error 2")));
ErrorReportingRunner sut = new ErrorReportingRunner(TestClassWithErrors.class, testClassError);
sut.run(new RunNotifier() {
@Override
public void fireTestFailure(Failure failure) {
super.fireTestFailure(failure);
firedFailures.add(failure);
}
});
assertThat(firedFailures.size(), is(1));
Throwable exception = firedFailures.get(0).getException();
assertThat(exception, instanceOf(InvalidTestClassError.class));
assertThat(((InvalidTestClassError) exception), is(testClassError));
}
use of org.junit.runner.notification.RunNotifier in project bazel by bazelbuild.
the class CancellableRequestFactory method cancelRun.
/**
* Cancels the request created by this request factory.
*/
public void cancelRun() {
cancelRequested = true;
RunNotifier notifier = currentNotifier;
if (notifier != null) {
notifier.pleaseStop();
}
}
use of org.junit.runner.notification.RunNotifier in project cucumber-jvm by cucumber.
the class JUnitReporterTest method match_allow_stared_ignored.
@Test
public void match_allow_stared_ignored() {
createAllowStartedIgnoredReporter();
Step runnerStep = mockStep();
Description runnerStepDescription = stepDescription(runnerStep);
ExecutionUnitRunner executionUnitRunner = mockExecutionUnitRunner(runnerSteps(runnerStep));
when(executionUnitRunner.describeChild(runnerStep)).thenReturn(runnerStepDescription);
runNotifier = mock(RunNotifier.class);
jUnitReporter.startExecutionUnit(executionUnitRunner, runNotifier);
jUnitReporter.startOfScenarioLifeCycle(mock(Scenario.class));
jUnitReporter.step(runnerStep);
jUnitReporter.match(mock(Match.class));
verify(runNotifier).fireTestStarted(executionUnitRunner.getDescription());
verify(runNotifier).fireTestStarted(runnerStepDescription);
}
use of org.junit.runner.notification.RunNotifier in project cucumber-jvm by cucumber.
the class JUnitReporterTest method creates_step_notifier_with_step_from_execution_unit_runner.
@Test
public void creates_step_notifier_with_step_from_execution_unit_runner() throws Exception {
Step runnerStep = mockStep("Step Name");
Description runnerStepDescription = stepDescription(runnerStep);
ExecutionUnitRunner executionUnitRunner = mockExecutionUnitRunner(runnerSteps(runnerStep));
when(executionUnitRunner.describeChild(runnerStep)).thenReturn(runnerStepDescription);
RunNotifier notifier = mock(RunNotifier.class);
jUnitReporter = new JUnitReporter(mock(Reporter.class), mock(Formatter.class), false, new JUnitOptions(Collections.<String>emptyList()));
jUnitReporter.startExecutionUnit(executionUnitRunner, notifier);
jUnitReporter.startOfScenarioLifeCycle(mock(Scenario.class));
jUnitReporter.step(mockStep("Step Name"));
jUnitReporter.match(mock(Match.class));
jUnitReporter.result(mockResult());
verify(notifier).fireTestFinished(runnerStepDescription);
}
use of org.junit.runner.notification.RunNotifier in project drools by kiegroup.
the class ScenarioRunner4JUnitTest method testNoKieWithGivenIDSession.
@Test
public void testNoKieWithGivenIDSession() throws Exception {
HashMap<String, KieSession> ksessions = new HashMap<String, KieSession>();
ksessions.put("someID", ksession);
Scenario scenario = new Scenario();
scenario.getKSessions().add("someOtherID");
ScenarioRunner4JUnit runner4JUnit = new ScenarioRunner4JUnit(scenario, ksessions);
RunNotifier notifier = new RunNotifier();
RunListener runListener = spy(new RunListener());
notifier.addListener(runListener);
runner4JUnit.run(notifier);
verify(runListener).testFailure(any(Failure.class));
}
Aggregations