use of org.junit.platform.fakes.TestDescriptorStub in project junit5 by junit-team.
the class TestIdentifierTests method inheritsTypeFromDescriptor.
@Test
void inheritsTypeFromDescriptor() {
TestDescriptor descriptor = new TestDescriptorStub(UniqueId.root("aType", "uniqueId"), "displayName");
var identifier = TestIdentifier.from(descriptor);
assertEquals(TestDescriptor.Type.TEST, identifier.getType());
assertTrue(identifier.isTest());
assertFalse(identifier.isContainer());
descriptor.addChild(new TestDescriptorStub(UniqueId.root("aChild", "uniqueId"), "displayName"));
identifier = TestIdentifier.from(descriptor);
assertEquals(TestDescriptor.Type.CONTAINER, identifier.getType());
assertFalse(identifier.isTest());
assertTrue(identifier.isContainer());
}
use of org.junit.platform.fakes.TestDescriptorStub in project junit5 by junit-team.
the class TestIdentifierTests method inheritsIdAndNamesFromDescriptor.
@Test
void inheritsIdAndNamesFromDescriptor() {
TestDescriptor testDescriptor = new TestDescriptorStub(UniqueId.root("aType", "uniqueId"), "displayName");
var testIdentifier = TestIdentifier.from(testDescriptor);
assertEquals("[aType:uniqueId]", testIdentifier.getUniqueId());
assertEquals("displayName", testIdentifier.getDisplayName());
}
use of org.junit.platform.fakes.TestDescriptorStub in project junit5 by junit-team.
the class EngineDiscoveryResultValidatorTests method detectCycleWithDoubleTest.
@Test
void detectCycleWithDoubleTest() {
var rootId = UniqueId.forEngine("root");
var root = new TestDescriptorStub(rootId, "root");
TestDescriptor group1 = new TestDescriptorStub(rootId.append("group", "1"), "1");
TestDescriptor group2 = new TestDescriptorStub(rootId.append("group", "2"), "2");
root.addChild(group1);
root.addChild(group2);
TestDescriptor test1 = new TestDescriptorStub(rootId.append("test", "1"), "1-1");
TestDescriptor test2 = new TestDescriptorStub(rootId.append("test", "2"), "2-2");
group1.addChild(test1);
group2.addChild(test2);
assertTrue(validator.isAcyclic(root));
group2.addChild(test1);
assertFalse(validator.isAcyclic(root));
}
use of org.junit.platform.fakes.TestDescriptorStub in project junit5 by junit-team.
the class EngineDiscoveryResultValidatorTests method detectCycleWithDoubleGroup.
@Test
void detectCycleWithDoubleGroup() {
var rootId = UniqueId.forEngine("root");
var root = new TestDescriptorStub(rootId, "root");
TestDescriptor group1 = new TestDescriptorStub(rootId.append("group", "1"), "1");
TestDescriptor group2 = new TestDescriptorStub(rootId.append("group", "2"), "2");
root.addChild(group1);
root.addChild(group2);
assertTrue(validator.isAcyclic(root));
group2.addChild(group1);
assertFalse(validator.isAcyclic(root));
}
use of org.junit.platform.fakes.TestDescriptorStub in project junit5 by junit-team.
the class DefaultLauncherTests method reportsDynamicTestDescriptorsCorrectly.
@Test
void reportsDynamicTestDescriptorsCorrectly() {
var engineId = UniqueId.forEngine(TestEngineSpy.ID);
var containerAndTestId = engineId.append("c&t", "c&t");
var dynamicTestId = containerAndTestId.append("test", "test");
var engine = new TestEngineSpy() {
@Override
public TestDescriptor discover(EngineDiscoveryRequest discoveryRequest, UniqueId uniqueId) {
super.discover(discoveryRequest, uniqueId);
var engineDescriptor = new TestDescriptorStub(uniqueId, uniqueId.toString());
engineDescriptor.addChild(new TestDescriptorStub(containerAndTestId, "c&t") {
@Override
public Type getType() {
return Type.CONTAINER_AND_TEST;
}
});
return engineDescriptor;
}
@Override
public void execute(ExecutionRequest request) {
super.execute(request);
var listener = request.getEngineExecutionListener();
listener.executionStarted(request.getRootTestDescriptor());
var containerAndTest = getOnlyElement(request.getRootTestDescriptor().getChildren());
listener.executionStarted(containerAndTest);
var dynamicTest = new TestDescriptorStub(dynamicTestId, "test");
dynamicTest.setParent(containerAndTest);
listener.dynamicTestRegistered(dynamicTest);
listener.executionStarted(dynamicTest);
listener.executionFinished(dynamicTest, successful());
listener.executionFinished(containerAndTest, successful());
listener.executionFinished(request.getRootTestDescriptor(), successful());
}
};
var launcher = createLauncher(engine);
var listener = mock(TestExecutionListener.class);
launcher.execute(request().build(), listener);
var inOrder = inOrder(listener);
var testPlanArgumentCaptor = ArgumentCaptor.forClass(TestPlan.class);
inOrder.verify(listener).testPlanExecutionStarted(testPlanArgumentCaptor.capture());
var testPlan = testPlanArgumentCaptor.getValue();
var engineTestIdentifier = testPlan.getTestIdentifier(engineId.toString());
var containerAndTestIdentifier = testPlan.getTestIdentifier(containerAndTestId.toString());
var dynamicTestIdentifier = testPlan.getTestIdentifier(dynamicTestId.toString());
assertThat(engineTestIdentifier.getParentId()).isEmpty();
assertThat(containerAndTestIdentifier.getParentId()).contains(engineId.toString());
assertThat(dynamicTestIdentifier.getParentId()).contains(containerAndTestId.toString());
inOrder.verify(listener).executionStarted(engineTestIdentifier);
inOrder.verify(listener).executionStarted(containerAndTestIdentifier);
inOrder.verify(listener).dynamicTestRegistered(dynamicTestIdentifier);
inOrder.verify(listener).executionStarted(dynamicTestIdentifier);
inOrder.verify(listener).executionFinished(dynamicTestIdentifier, successful());
inOrder.verify(listener).executionFinished(containerAndTestIdentifier, successful());
inOrder.verify(listener).executionFinished(engineTestIdentifier, successful());
inOrder.verify(listener).testPlanExecutionFinished(same(testPlan));
}
Aggregations