Search in sources :

Example 11 with Failure

use of org.junit.runner.notification.Failure in project junit4 by junit-team.

the class ResultMatchersTest method hasFailureContaining_givenResultWithNoFailures.

@Test
public void hasFailureContaining_givenResultWithNoFailures() {
    PrintableResult resultWithNoFailures = new PrintableResult(new ArrayList<Failure>());
    assertThat(ResultMatchers.hasFailureContaining("").matches(resultWithNoFailures), is(false));
}
Also used : PrintableResult(org.junit.experimental.results.PrintableResult) Failure(org.junit.runner.notification.Failure) Test(org.junit.Test)

Example 12 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 13 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 14 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 15 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)

Aggregations

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