use of org.junit.jupiter.api.DynamicContainer in project junit5 by junit-team.
the class TestFactoryTestDescriptor method createDynamicDescriptor.
static Optional<JupiterTestDescriptor> createDynamicDescriptor(JupiterTestDescriptor parent, DynamicNode node, int index, TestSource source, DynamicDescendantFilter dynamicDescendantFilter) {
UniqueId uniqueId;
Supplier<JupiterTestDescriptor> descriptorCreator;
if (node instanceof DynamicTest) {
DynamicTest test = (DynamicTest) node;
uniqueId = parent.getUniqueId().append(DYNAMIC_TEST_SEGMENT_TYPE, "#" + index);
descriptorCreator = () -> new DynamicTestTestDescriptor(uniqueId, index, test, source);
} else {
DynamicContainer container = (DynamicContainer) node;
uniqueId = parent.getUniqueId().append(DYNAMIC_CONTAINER_SEGMENT_TYPE, "#" + index);
descriptorCreator = () -> new DynamicContainerTestDescriptor(uniqueId, index, container, source, dynamicDescendantFilter);
}
if (dynamicDescendantFilter.test(uniqueId)) {
JupiterTestDescriptor descriptor = descriptorCreator.get();
parent.addChild(descriptor);
return Optional.of(descriptor);
}
return Optional.empty();
}
Aggregations