use of org.junit.runner.Description in project junit4 by junit-team.
the class AnnotationTest method testErrorInBeforeClass.
public void testErrorInBeforeClass() throws Exception {
run = false;
JUnitCore core = new JUnitCore();
Result result = core.run(ErrorInBeforeClass.class);
assertFalse(run);
assertEquals(1, result.getFailureCount());
Description description = result.getFailures().get(0).getDescription();
assertEquals(ErrorInBeforeClass.class.getName(), description.getDisplayName());
}
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;
}
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();
}
use of org.junit.runner.Description in project junit4 by junit-team.
the class ParentRunner method getDescription.
//
// Implementation of Runner
//
@Override
public Description getDescription() {
Class<?> clazz = getTestClass().getJavaClass();
Description description;
// to maintain backwards compatibility with JUnit 4.12
if (clazz == null || !clazz.getName().equals(getName())) {
description = Description.createSuiteDescription(getName(), getRunnerAnnotations());
} else {
description = Description.createSuiteDescription(clazz, getRunnerAnnotations());
}
for (T child : getFilteredChildren()) {
description.addChild(describeChild(child));
}
return description;
}
use of org.junit.runner.Description in project mockito by mockito.
the class UnnecessaryStubbingsReporter method validateUnusedStubs.
public void validateUnusedStubs(Class<?> testClass, RunNotifier notifier) {
Collection<Invocation> unused = new UnusedStubbingsFinder().getUnusedStubbingsByLocation(mocks);
if (unused.size() == 0) {
//whoa!!! All stubbings were used!
return;
}
//Oups, there are unused stubbings
Description unnecessaryStubbings = Description.createTestDescription(testClass, "unnecessary Mockito stubbings");
notifier.fireTestFailure(new Failure(unnecessaryStubbings, Reporter.formatUnncessaryStubbingException(testClass, unused)));
}
Aggregations