use of org.junit.runner.Description in project junit5 by junit-team.
the class OrFilterTests method evaluatesMultipleFilters.
@Test
void evaluatesMultipleFilters() {
Filter filter1 = mockFilter("foo", false);
Filter filter2 = mockFilter("bar", true);
OrFilter orFilter = new OrFilter(asList(filter1, filter2));
assertEquals("foo OR bar", orFilter.describe());
Description description = Description.createTestDescription(getClass(), "evaluatesMultipleFilters");
assertTrue(orFilter.shouldRun(description));
verify(filter1).shouldRun(same(description));
verify(filter2).shouldRun(same(description));
}
use of org.junit.runner.Description in project junit5 by junit-team.
the class TestRunTests method registersDynamicTestDescriptors.
@Test
void registersDynamicTestDescriptors() throws Exception {
Class<?> testClass = PlainJUnit4TestCaseWithSingleTestWhichFails.class;
UniqueId runnerId = engineId().append(SEGMENT_TYPE_RUNNER, testClass.getName());
RunnerTestDescriptor runnerTestDescriptor = new RunnerTestDescriptor(runnerId, testClass, new BlockJUnit4ClassRunner(testClass));
UniqueId dynamicTestId = runnerId.append(SEGMENT_TYPE_DYNAMIC, "dynamicTest");
Description dynamicDescription = createTestDescription(testClass, "dynamicTest");
VintageTestDescriptor dynamicTestDescriptor = new VintageTestDescriptor(dynamicTestId, dynamicDescription);
TestRun testRun = new TestRun(runnerTestDescriptor);
testRun.registerDynamicTest(dynamicTestDescriptor);
assertThat(testRun.lookupTestDescriptor(dynamicDescription)).contains(dynamicTestDescriptor);
assertTrue(testRun.isDescendantOfRunnerTestDescriptor(dynamicTestDescriptor));
}
use of org.junit.runner.Description in project junit5 by junit-team.
the class ConfigurableRunner method getDescription.
@Override
public Description getDescription() {
Description suiteDescription = Description.createSuiteDescription(testClass);
ChildCount childCountAnnotation = testClass.getAnnotation(ChildCount.class);
int childCount = Optional.ofNullable(childCountAnnotation).map(ChildCount::value).orElse(0);
// @formatter:off
range(0, childCount).mapToObj(index -> Description.createTestDescription(testClass, "Test #" + index)).forEach(suiteDescription::addChild);
// @formatter:on
return suiteDescription;
}
use of org.junit.runner.Description in project junit5 by junit-team.
the class UniqueIdReaderTests method readsUniqueId.
@Test
void readsUniqueId(LogRecordListener listener) {
Description description = createTestDescription("ClassName", "methodName", "uniqueId");
Serializable uniqueId = new UniqueIdReader().apply(description);
assertEquals("uniqueId", uniqueId);
assertThat(listener.stream(UniqueIdReader.class)).isEmpty();
}
use of org.junit.runner.Description in project tck by dmn-tck.
the class DmnTckRunner method runChild.
@Override
protected void runChild(TestCases.TestCase testCase, RunNotifier runNotifier) {
Description description = this.children.get(testCase);
try {
runNotifier.fireTestStarted(description);
vendorSuite.beforeTest(description, context, testCase);
TestResult result = vendorSuite.executeTest(description, context, testCase);
switch(result.getResult()) {
case SUCCESS:
runNotifier.fireTestFinished(description);
break;
case IGNORED:
runNotifier.fireTestIgnored(description);
break;
case ERROR:
runNotifier.fireTestFailure(new Failure(description, new RuntimeException(result.toStringWithLines())));
break;
}
if (resultFile != null) {
String relativePath = relativePath(folder);
resultFile.append(String.format("\"%s\",\"%s\",\"%s\",\"%s\",\"%s\"\n", relativePath, description.getClassName(), description.getMethodName(), result.getResult().toString(), result.getMsg()));
}
} catch (IOException e) {
e.printStackTrace();
} finally {
vendorSuite.afterTest(description, context, testCase);
runNotifier.fireTestFinished(description);
}
}
Aggregations