Search in sources :

Example 1 with WarningsCollector

use of org.mockito.internal.debugging.WarningsCollector 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 2 with WarningsCollector

use of org.mockito.internal.debugging.WarningsCollector 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)

Aggregations

Description (org.junit.runner.Description)2 Failure (org.junit.runner.notification.Failure)2 RunListener (org.junit.runner.notification.RunListener)2 WarningsCollector (org.mockito.internal.debugging.WarningsCollector)2 JUnitFailureHacker (org.mockito.internal.junit.util.JUnitFailureHacker)1