Search in sources :

Example 96 with Description

use of org.junit.runner.Description in project ceylon-compiler by ceylon.

the class CeylonTestGroup method runChild.

@Override
protected void runChild(Runner method, RunNotifier notifier) {
    Description description = describeChild(method);
    notifier.fireTestStarted(description);
    Failure failure = null;
    try {
        method.run(notifier);
    } finally {
        if (failure != null) {
            notifier.fireTestFailure(failure);
        }
    }
    notifier.fireTestFinished(description);
}
Also used : Description(org.junit.runner.Description) Failure(org.junit.runner.notification.Failure)

Example 97 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 98 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 99 with Description

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

the class ParentRunnerFilteringTest method testCountClassFiltering.

@Test
public void testCountClassFiltering() throws Exception {
    JUnitCore junitCore = new JUnitCore();
    Request request = Request.aClass(ExampleTest.class);
    CountingFilter countingFilter = new CountingFilter();
    Request requestFiltered = request.filterWith(countingFilter);
    Result result = junitCore.run(requestFiltered);
    assertEquals(1, result.getRunCount());
    assertEquals(0, result.getFailureCount());
    Description desc = createTestDescription(ExampleTest.class, "test1");
    assertEquals(1, countingFilter.getCount(desc));
}
Also used : Description.createTestDescription(org.junit.runner.Description.createTestDescription) Description(org.junit.runner.Description) Description.createSuiteDescription(org.junit.runner.Description.createSuiteDescription) JUnitCore(org.junit.runner.JUnitCore) Request(org.junit.runner.Request) Result(org.junit.runner.Result) PrintableResult.testResult(org.junit.experimental.results.PrintableResult.testResult) Test(org.junit.Test)

Example 100 with Description

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

the class JUnit38ClassRunnerTest method testListener.

@Test
public void testListener() throws Exception {
    JUnitCore runner = new JUnitCore();
    RunListener listener = new RunListener() {

        @Override
        public void testStarted(Description description) {
            assertEquals(Description.createTestDescription(OneTest.class, "testOne"), description);
            count++;
        }
    };
    runner.addListener(listener);
    count = 0;
    Result result = runner.run(OneTest.class);
    assertEquals(1, count);
    assertEquals(1, result.getRunCount());
}
Also used : Description(org.junit.runner.Description) JUnitCore(org.junit.runner.JUnitCore) RunListener(org.junit.runner.notification.RunListener) Result(org.junit.runner.Result) Test(org.junit.Test)

Aggregations

Description (org.junit.runner.Description)309 Test (org.junit.Test)119 Failure (org.junit.runner.notification.Failure)57 Result (org.junit.runner.Result)32 ArrayList (java.util.ArrayList)25 RunListener (org.junit.runner.notification.RunListener)23 IOException (java.io.IOException)22 Request (org.junit.runner.Request)21 Method (java.lang.reflect.Method)18 JUnitCore (org.junit.runner.JUnitCore)17 Test (org.junit.jupiter.api.Test)14 Filter (org.junit.runner.manipulation.Filter)14 File (java.io.File)13 Runner (org.junit.runner.Runner)13 Statement (org.junit.runners.model.Statement)13 LoggingListener (org.elasticsearch.test.junit.listeners.LoggingListener)12 RunNotifier (org.junit.runner.notification.RunNotifier)12 JUnit4TestListener (com.intellij.junit4.JUnit4TestListener)10 ComparisonFailure (org.junit.ComparisonFailure)10 Description.createTestDescription (org.junit.runner.Description.createTestDescription)9