use of org.junit.platform.engine.UniqueId 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.platform.engine.UniqueId in project cucumber-jvm by cucumber.
the class CucumberTestEngineTest method createExecutionContext.
@Test
void createExecutionContext() {
EngineExecutionListener listener = new EmptyEngineExecutionListener();
ConfigurationParameters configuration = new EmptyConfigurationParameters();
EngineDiscoveryRequest discoveryRequest = new EmptyEngineDiscoveryRequest(configuration);
UniqueId id = UniqueId.forEngine(engine.getId());
TestDescriptor testDescriptor = engine.discover(discoveryRequest, id);
ExecutionRequest execution = new ExecutionRequest(testDescriptor, listener, configuration);
assertNotNull(engine.createExecutionContext(execution));
}
use of org.junit.platform.engine.UniqueId in project cucumber-jvm by cucumber.
the class DiscoverySelectorResolverTest method before.
@BeforeEach
void before() {
LoggerFactory.addListener(logRecordListener);
UniqueId id = UniqueId.forEngine(new CucumberTestEngine().getId());
testDescriptor = new CucumberEngineDescriptor(id);
assertEquals(0, testDescriptor.getChildren().size());
}
use of org.junit.platform.engine.UniqueId in project graylog2-server by Graylog2.
the class ContainerMatrixClassSelectorResolver method resolve.
@Override
public Resolution resolve(UniqueIdSelector selector, Context context) {
UniqueId uniqueId = selector.getUniqueId();
UniqueId.Segment lastSegment = uniqueId.getLastSegment();
if (ContainerMatrixTestClassDescriptor.SEGMENT_TYPE.equals(lastSegment.getType())) {
String className = lastSegment.getValue();
return ReflectionUtils.tryToLoadClass(className).toOptional().filter(isTestClassWithTests).map(testClass -> toResolution(context.addToParent(parent -> Optional.of(newClassTestDescriptor(parent, testClass))))).orElse(unresolved());
}
if (NestedClassTestDescriptor.SEGMENT_TYPE.equals(lastSegment.getType())) {
String simpleClassName = lastSegment.getValue();
return toResolution(context.addToParent(() -> selectUniqueId(uniqueId.removeLastSegment()), parent -> {
if (parent instanceof ClassBasedTestDescriptor) {
Class<?> parentTestClass = ((ClassBasedTestDescriptor) parent).getTestClass();
return ReflectionUtils.findNestedClasses(parentTestClass, isNestedTestClass.and(where(Class::getSimpleName, isEqual(simpleClassName)))).stream().findFirst().flatMap(testClass -> Optional.of(newNestedClassTestDescriptor(parent, testClass)));
}
return Optional.empty();
}));
}
return unresolved();
}
use of org.junit.platform.engine.UniqueId in project intellij-community by JetBrains.
the class JUnit5NavigationTest method methodNavigation.
@Test
void methodNavigation() throws Exception {
UniqueId uniqueId = UniqueId.parse("[class:JUnit5NavigationTest]/[method:methodNavigation]");
MethodTestDescriptor methodTestDescriptor = new MethodTestDescriptor(uniqueId, JUnit5NavigationTest.class, JUnit5NavigationTest.class.getDeclaredMethod("methodNavigation"));
TestIdentifier testIdentifier = TestIdentifier.from(methodTestDescriptor);
Assertions.assertEquals(JUnit5NavigationTest.class.getName(), JUnit5TestExecutionListener.getClassName(testIdentifier));
Assertions.assertEquals("methodNavigation", JUnit5TestExecutionListener.getMethodName(testIdentifier));
//Assertions.assertEquals("methodNavigation", testIdentifier.getDisplayName()); todo methodNavigation()
}
Aggregations