Search in sources :

Example 16 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)

Example 17 with Failure

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

the class MaxStarterTest method correctErrorFromHalfMalformedTest.

@Test
public void correctErrorFromHalfMalformedTest() {
    Request request = Request.aClass(HalfMalformedJUnit38TestMethod.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 18 with Failure

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

the class PrintableResultTest method includeMultipleFailures.

@Theory
public void includeMultipleFailures(String secondExceptionName) {
    PrintableResult backtrace = new PrintableResult(Arrays.asList(new Failure(Description.createSuiteDescription("firstName"), new RuntimeException("firstException")), new Failure(Description.createSuiteDescription("secondName"), new RuntimeException(secondExceptionName))));
    assertThat(backtrace.toString(), containsString(secondExceptionName));
}
Also used : PrintableResult(org.junit.experimental.results.PrintableResult) Failure(org.junit.runner.notification.Failure) Theory(org.junit.experimental.theories.Theory)

Example 19 with Failure

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

the class PrintableResultTest method backTraceHasGoodToString.

@Theory(nullsAccepted = false)
public void backTraceHasGoodToString(String descriptionName, final String stackTraceClassName) {
    Failure failure = new Failure(Description.createSuiteDescription(descriptionName), new Throwable() {

        private static final long serialVersionUID = 1L;

        @Override
        public StackTraceElement[] getStackTrace() {
            return new StackTraceElement[] { new StackTraceElement(stackTraceClassName, "methodName", "fileName", 1) };
        }
    });
    assertThat(new PrintableResult(asList(failure)).toString(), allOf(containsString(descriptionName), containsString(stackTraceClassName)));
}
Also used : PrintableResult(org.junit.experimental.results.PrintableResult) Failure(org.junit.runner.notification.Failure) Theory(org.junit.experimental.theories.Theory)

Example 20 with Failure

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

the class TimeoutRuleTest method nullTimeUnit.

@Test
public void nullTimeUnit() {
    Result result = JUnitCore.runClasses(HasNullTimeUnit.class);
    assertEquals(1, result.getFailureCount());
    Failure failure = result.getFailures().get(0);
    assertThat(failure.getException().getMessage(), containsString("Invalid parameters for Timeout"));
    Throwable cause = failure.getException().getCause();
    assertThat(cause.getMessage(), containsString("TimeUnit cannot be null"));
}
Also used : 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