Search in sources :

Example 36 with Failure

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."));
}
Also used : Failure(org.junit.runner.notification.Failure) Result(org.junit.runner.Result) PrintableResult.testResult(org.junit.experimental.results.PrintableResult.testResult) Test(org.junit.Test)

Example 37 with Failure

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());
}
Also used : JUnitCore(org.junit.runner.JUnitCore) JUnit38ClassRunner(org.junit.internal.runners.JUnit38ClassRunner) JUnit4TestAdapter(junit.framework.JUnit4TestAdapter) Failure(org.junit.runner.notification.Failure) Result(org.junit.runner.Result) Test(org.junit.Test)

Example 38 with Failure

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;
}
Also used : JUnitCore(org.junit.runner.JUnitCore) ArrayList(java.util.ArrayList) Failure(org.junit.runner.notification.Failure) RunListener(org.junit.runner.notification.RunListener)

Example 39 with Failure

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"));
}
Also used : JUnit38ClassRunner(org.junit.internal.runners.JUnit38ClassRunner) Runner(org.junit.runner.Runner) JUnitCore(org.junit.runner.JUnitCore) Request(org.junit.runner.Request) Failure(org.junit.runner.notification.Failure) Result(org.junit.runner.Result) Test(org.junit.Test)

Example 40 with Failure

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());
}
Also used : MaxCore(org.junit.experimental.max.MaxCore) Failure(org.junit.runner.notification.Failure) Test(org.junit.Test)

Aggregations

Failure (org.junit.runner.notification.Failure)194 Test (org.junit.Test)101 Result (org.junit.runner.Result)91 Description (org.junit.runner.Description)40 IOException (java.io.IOException)32 UnitTest (org.apache.geode.test.junit.categories.UnitTest)27 JUnitCore (org.junit.runner.JUnitCore)24 FileInputStream (java.io.FileInputStream)20 InputStream (java.io.InputStream)20 RunListener (org.junit.runner.notification.RunListener)19 ArrayList (java.util.ArrayList)11 ByteArrayInputStream (java.io.ByteArrayInputStream)9 ComparisonFailure (org.junit.ComparisonFailure)9 JUnit4TestListener (com.intellij.junit4.JUnit4TestListener)7 RunNotifier (org.junit.runner.notification.RunNotifier)7 ResourceImpl (ddf.catalog.resource.impl.ResourceImpl)6 Request (org.junit.runner.Request)6 BinaryContentImpl (ddf.catalog.data.impl.BinaryContentImpl)5 Before (org.junit.Before)5 Runner (org.junit.runner.Runner)5