Search in sources :

Example 21 with Description

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

the class AnnotationTest method testErrorInBeforeClass.

public void testErrorInBeforeClass() throws Exception {
    run = false;
    JUnitCore core = new JUnitCore();
    Result result = core.run(ErrorInBeforeClass.class);
    assertFalse(run);
    assertEquals(1, result.getFailureCount());
    Description description = result.getFailures().get(0).getDescription();
    assertEquals(ErrorInBeforeClass.class.getName(), description.getDisplayName());
}
Also used : Description(org.junit.runner.Description) JUnitCore(org.junit.runner.JUnitCore) Result(org.junit.runner.Result) PrintableResult.testResult(org.junit.experimental.results.PrintableResult.testResult)

Example 22 with Description

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

the class JUnit4ClassRunner method getDescription.

@Override
public Description getDescription() {
    Description spec = Description.createSuiteDescription(getName(), classAnnotations());
    List<Method> testMethods = this.testMethods;
    for (Method method : testMethods) {
        spec.addChild(methodDescription(method));
    }
    return spec;
}
Also used : Description(org.junit.runner.Description) Method(java.lang.reflect.Method)

Example 23 with Description

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

the class JUnit4ClassRunner method invokeTestMethod.

protected void invokeTestMethod(Method method, RunNotifier notifier) {
    Description description = methodDescription(method);
    Object test;
    try {
        test = createTest();
    } catch (InvocationTargetException e) {
        testAborted(notifier, description, e.getCause());
        return;
    } catch (Exception e) {
        testAborted(notifier, description, e);
        return;
    }
    TestMethod testMethod = wrapMethod(method);
    new MethodRoadie(test, testMethod, notifier, description).run();
}
Also used : Description(org.junit.runner.Description) InvocationTargetException(java.lang.reflect.InvocationTargetException) NoTestsRemainException(org.junit.runner.manipulation.NoTestsRemainException) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 24 with Description

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

the class ParentRunner method getDescription.

//
// Implementation of Runner
//
@Override
public Description getDescription() {
    Class<?> clazz = getTestClass().getJavaClass();
    Description description;
    // to maintain backwards compatibility with JUnit 4.12
    if (clazz == null || !clazz.getName().equals(getName())) {
        description = Description.createSuiteDescription(getName(), getRunnerAnnotations());
    } else {
        description = Description.createSuiteDescription(clazz, getRunnerAnnotations());
    }
    for (T child : getFilteredChildren()) {
        description.addChild(describeChild(child));
    }
    return description;
}
Also used : Description(org.junit.runner.Description)

Example 25 with Description

use of org.junit.runner.Description in project mockito by mockito.

the class UnnecessaryStubbingsReporter method validateUnusedStubs.

public void validateUnusedStubs(Class<?> testClass, RunNotifier notifier) {
    Collection<Invocation> unused = new UnusedStubbingsFinder().getUnusedStubbingsByLocation(mocks);
    if (unused.size() == 0) {
        //whoa!!! All stubbings were used!
        return;
    }
    //Oups, there are unused stubbings
    Description unnecessaryStubbings = Description.createTestDescription(testClass, "unnecessary Mockito stubbings");
    notifier.fireTestFailure(new Failure(unnecessaryStubbings, Reporter.formatUnncessaryStubbingException(testClass, unused)));
}
Also used : Description(org.junit.runner.Description) Invocation(org.mockito.invocation.Invocation) Failure(org.junit.runner.notification.Failure)

Aggregations

Description (org.junit.runner.Description)182 Test (org.junit.Test)84 Failure (org.junit.runner.notification.Failure)40 Result (org.junit.runner.Result)27 ArrayList (java.util.ArrayList)20 Request (org.junit.runner.Request)20 RunListener (org.junit.runner.notification.RunListener)19 JUnitCore (org.junit.runner.JUnitCore)16 IOException (java.io.IOException)13 Method (java.lang.reflect.Method)12 Filter (org.junit.runner.manipulation.Filter)11 JUnit4TestListener (com.intellij.junit4.JUnit4TestListener)10 Runner (org.junit.runner.Runner)9 RunNotifier (org.junit.runner.notification.RunNotifier)9 ComparisonFailure (org.junit.ComparisonFailure)8 InOrder (org.mockito.InOrder)8 TestSuiteModel (com.google.testing.junit.runner.model.TestSuiteModel)7 Statement (org.junit.runners.model.Statement)7 Subscribe (com.google.common.eventbus.Subscribe)6 Step (gherkin.formatter.model.Step)6