use of org.junit.runner.Description in project elasticsearch by elastic.
the class LoggingListenerTests method testTestRunStartedSupportsClassInDefaultPackage.
public void testTestRunStartedSupportsClassInDefaultPackage() throws Exception {
LoggingListener loggingListener = new LoggingListener();
Description description = Description.createTestDescription(Class.forName("Dummy"), "dummy");
// Will throw an exception without the check for testClassPackage != null in testRunStarted
loggingListener.testRunStarted(description);
}
use of org.junit.runner.Description in project elasticsearch by elastic.
the class LoggingListenerTests method testInvalidMethodTestLoggingAnnotation.
public void testInvalidMethodTestLoggingAnnotation() throws Exception {
final LoggingListener loggingListener = new LoggingListener();
final Description suiteDescription = Description.createSuiteDescription(InvalidMethod.class);
loggingListener.testRunStarted(suiteDescription);
final Method method = InvalidMethod.class.getMethod("invalidMethod");
final TestLogging annotation = method.getAnnotation(TestLogging.class);
Description testDescription = Description.createTestDescription(InvalidMethod.class, "invalidMethod", annotation);
final IllegalArgumentException e = expectThrows(IllegalArgumentException.class, () -> loggingListener.testStarted(testDescription));
assertThat(e.getMessage(), equalTo("invalid test logging annotation [abc:INFO:WARN]"));
}
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);
}
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);
}
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);
}
Aggregations