Search in sources :

Example 41 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 42 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 43 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 44 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)

Example 45 with Failure

use of org.junit.runner.notification.Failure in project pinpoint by naver.

the class PinpointPluginTestStatement method toFailure.

private Failure toFailure(Description parentDescription, String displayName, String exceptionClass, String message, List<String> trace) {
    Description desc = findDescription(parentDescription, displayName);
    Exception exception = toException(message, exceptionClass, trace);
    Failure failure = new Failure(desc, exception);
    return failure;
}
Also used : Description(org.junit.runner.Description) Failure(org.junit.runner.notification.Failure)

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