Search in sources :

Example 1 with JUnitFailureHacker

use of org.mockito.internal.junit.util.JUnitFailureHacker 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)1 Failure (org.junit.runner.notification.Failure)1 RunListener (org.junit.runner.notification.RunListener)1 WarningsCollector (org.mockito.internal.debugging.WarningsCollector)1 JUnitFailureHacker (org.mockito.internal.junit.util.JUnitFailureHacker)1