Search in sources :

Example 26 with Description

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

the class ConsoleSpammingMockitoJUnitRunner method run.

@Override
public void run(RunNotifier notifier) {
    RunListener listener = new RunListener() {

        WarningsCollector warningsCollector;

        @Override
        public void testStarted(Description description) throws Exception {
            warningsCollector = new WarningsCollector();
        }

        @Override
        public void testFailure(Failure failure) throws Exception {
            logger.log(warningsCollector.getWarnings());
        }
    };
    notifier.addListener(listener);
    runner.run(notifier);
}
Also used : Description(org.junit.runner.Description) WarningsCollector(org.mockito.internal.debugging.WarningsCollector) Failure(org.junit.runner.notification.Failure) RunListener(org.junit.runner.notification.RunListener)

Example 27 with Description

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

the class VerboseMockitoJUnitRunner method run.

@Override
public void run(RunNotifier notifier) {
    //a listener that changes the failure's exception in a very hacky way...
    RunListener listener = new RunListener() {

        WarningsCollector warningsCollector;

        @Override
        public void testStarted(Description description) throws Exception {
            warningsCollector = new WarningsCollector();
        }

        @Override
        @SuppressWarnings("deprecation")
        public void testFailure(final Failure failure) throws Exception {
            String warnings = warningsCollector.getWarnings();
            new JUnitFailureHacker().appendWarnings(failure, warnings);
        }
    };
    notifier.addFirstListener(listener);
    runner.run(notifier);
}
Also used : Description(org.junit.runner.Description) JUnitFailureHacker(org.mockito.internal.junit.util.JUnitFailureHacker) WarningsCollector(org.mockito.internal.debugging.WarningsCollector) Failure(org.junit.runner.notification.Failure) RunListener(org.junit.runner.notification.RunListener)

Example 28 with Description

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

the class ConsoleSpammingMockitoJUnitRunnerTest method shouldDelegateToGetDescription.

//TODO add sensible tests
@Test
public void shouldDelegateToGetDescription() throws Exception {
    //given
    final Description expectedDescription = Description.createSuiteDescription(this.getClass());
    runner = new ConsoleSpammingMockitoJUnitRunner(loggerStub, new InternalRunnerStub() {

        public Description getDescription() {
            return expectedDescription;
        }
    });
    //when
    Description description = runner.getDescription();
    //then
    assertEquals(expectedDescription, description);
}
Also used : Description(org.junit.runner.Description) Test(org.junit.Test)

Example 29 with Description

use of org.junit.runner.Description 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)

Example 30 with Description

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

the class ResourceRule method fileInExistingDirectory.

public static ResourceRule<File> fileInExistingDirectory(final Supplier<? extends FileSystemAbstraction> fs) {
    return new ResourceRule<File>() {

        @Override
        protected File createResource(Description description) {
            File path = path(description);
            fs.get().mkdir(path.getParentFile());
            return path;
        }
    };
}
Also used : Description(org.junit.runner.Description) File(java.io.File)

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