use of org.junit.vintage.engine.descriptor.RunnerTestDescriptor 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.vintage.engine.descriptor.RunnerTestDescriptor in project junit5 by junit-team.
the class TestRunTests method returnsEmptyOptionalForUnknownDescriptions.
@Test
void returnsEmptyOptionalForUnknownDescriptions() throws Exception {
Class<?> testClass = PlainJUnit4TestCaseWithSingleTestWhichFails.class;
UniqueId runnerId = engineId().append(SEGMENT_TYPE_RUNNER, testClass.getName());
RunnerTestDescriptor runnerTestDescriptor = new RunnerTestDescriptor(runnerId, testClass, new BlockJUnit4ClassRunner(testClass));
Description unknownDescription = createTestDescription(testClass, "dynamicTest");
TestRun testRun = new TestRun(runnerTestDescriptor);
Optional<VintageTestDescriptor> testDescriptor = testRun.lookupTestDescriptor(unknownDescription);
assertThat(testDescriptor).isEmpty();
}
use of org.junit.vintage.engine.descriptor.RunnerTestDescriptor in project junit5 by junit-team.
the class TestClassRequestResolver method createCompleteRunnerTestDescriptor.
private RunnerTestDescriptor createCompleteRunnerTestDescriptor(Class<?> testClass, Runner runner, UniqueId engineId) {
UniqueId id = engineId.append(SEGMENT_TYPE_RUNNER, testClass.getName());
RunnerTestDescriptor runnerTestDescriptor = new RunnerTestDescriptor(id, testClass, runner);
addChildrenRecursively(runnerTestDescriptor);
return runnerTestDescriptor;
}
use of org.junit.vintage.engine.descriptor.RunnerTestDescriptor in project junit5 by junit-team.
the class TestClassRequestResolver method determineRunnerTestDescriptor.
private RunnerTestDescriptor determineRunnerTestDescriptor(Class<?> testClass, Runner runner, List<RunnerTestDescriptorAwareFilter> filters, UniqueId engineId) {
RunnerTestDescriptor runnerTestDescriptor = createCompleteRunnerTestDescriptor(testClass, runner, engineId);
if (!filters.isEmpty()) {
if (runner instanceof Filterable) {
Filter filter = createOrFilter(filters, runnerTestDescriptor);
Runner filteredRunner = runnerTestDescriptor.toRequest().filterWith(filter).getRunner();
runnerTestDescriptor = createCompleteRunnerTestDescriptor(testClass, filteredRunner, engineId);
} else {
Runner runnerToReport = (runner instanceof RunnerDecorator) ? ((RunnerDecorator) runner).getDecoratedRunner() : runner;
logger.warn(() -> //
"Runner " + runnerToReport.getClass().getName() + " (used on " + testClass.getName() + //
") does not support filtering" + " and will therefore be run completely.");
}
}
return runnerTestDescriptor;
}
Aggregations