use of org.junit.runner.notification.Failure in project junit4 by junit-team.
the class ParameterizedTestTest method numberOfFieldsAndParametersShouldMatch.
@Test
public void numberOfFieldsAndParametersShouldMatch() {
Result result = JUnitCore.runClasses(BadNumberOfAnnotatedFieldTest.class);
assertEquals(1, result.getFailureCount());
List<Failure> failures = result.getFailures();
assertTrue(failures.get(0).getException().getMessage().contains("Wrong number of parameters and @Parameter fields. @Parameter fields counted: 1, available parameters: 2."));
}
use of org.junit.runner.notification.Failure in project junit4 by junit-team.
the class JUnit38ClassRunnerTest method canUnadaptAnAdapter.
@Test
public void canUnadaptAnAdapter() {
JUnit38ClassRunner runner = new JUnit38ClassRunner(new JUnit4TestAdapter(AnnotatedTest.class));
Result result = new JUnitCore().run(runner);
Failure failure = result.getFailures().get(0);
assertEquals(Description.createTestDescription(AnnotatedTest.class, "foo"), failure.getDescription());
}
use of org.junit.runner.notification.Failure in project junit4 by junit-team.
the class AssumptionTest method runAndGetAssumptionFailures.
/**
* Helper method that runs tests on <code>clazz</code> and returns any
* {@link Failure} objects that were {@link AssumptionViolatedException}s.
*/
private static List<Failure> runAndGetAssumptionFailures(Class<?> clazz) {
final List<Failure> failures = new ArrayList<Failure>();
final JUnitCore core = new JUnitCore();
core.addListener(new RunListener() {
@Override
public void testAssumptionFailure(Failure failure) {
failures.add(failure);
}
});
core.run(clazz);
return failures;
}
use of org.junit.runner.notification.Failure in project junit4 by junit-team.
the class MaxStarterTest method correctErrorFromMalformedTest.
@Test
public void correctErrorFromMalformedTest() {
Request request = Request.aClass(MalformedJUnit38TestMethod.class);
JUnitCore core = new JUnitCore();
Request sorted = fMax.sortRequest(request);
Runner runner = sorted.getRunner();
Result result = core.run(runner);
Failure failure = result.getFailures().get(0);
assertThat(failure.toString(), containsString("MalformedJUnit38TestMethod"));
assertThat(failure.toString(), containsString("testNothing"));
assertThat(failure.toString(), containsString("isn't public"));
}
use of org.junit.runner.notification.Failure in project junit4 by junit-team.
the class MaxStarterTest method rememberOldRuns.
@Test
public void rememberOldRuns() {
fMax.run(TwoUnEqualTests.class);
MaxCore reincarnation = MaxCore.storedLocally(fMaxFile);
List<Failure> failures = reincarnation.run(TwoUnEqualTests.class).getFailures();
assertEquals("fast", failures.get(0).getDescription().getMethodName());
assertEquals("slow", failures.get(1).getDescription().getMethodName());
}
Aggregations