use of org.junit.platform.launcher.TestIdentifier in project junit5 by junit-team.
the class VintageLauncherIntegrationTests method removesCompleteClassWithNotFilterableRunnerIfItHasExcludedTag.
@Test
void removesCompleteClassWithNotFilterableRunnerIfItHasExcludedTag() {
Class<?> testClass = JUnit4TestCaseWithNotFilterableRunner.class;
LauncherDiscoveryRequestBuilder request = //
request().selectors(//
selectClass(testClass)).filters(excludeTags(Categories.Successful.class.getName()));
TestPlan testPlan = discover(request);
assertThat(testPlan.getDescendants(getOnlyElement(testPlan.getRoots()))).isEmpty();
Map<TestIdentifier, TestExecutionResult> results = execute(request);
//
assertThat(results.keySet().stream().map(TestIdentifier::getDisplayName)).containsExactly("JUnit Vintage");
}
use of org.junit.platform.launcher.TestIdentifier in project mockito by mockito.
the class StrictnessTest method invokeTestClassAndRetrieveMethodResult.
private TestExecutionResult invokeTestClassAndRetrieveMethodResult(Class<?> clazz) {
LauncherDiscoveryRequest request = LauncherDiscoveryRequestBuilder.request().selectors(selectClass(clazz)).build();
Launcher launcher = LauncherFactory.create();
final TestExecutionResult[] result = new TestExecutionResult[1];
launcher.registerTestExecutionListeners(new TestExecutionListener() {
@Override
public void executionFinished(TestIdentifier testIdentifier, TestExecutionResult testExecutionResult) {
if (testIdentifier.getDisplayName().endsWith("()")) {
result[0] = testExecutionResult;
}
}
});
launcher.execute(request);
return result[0];
}
use of org.junit.platform.launcher.TestIdentifier in project gradle by gradle.
the class JUnitPlatformTestExecutionListener method createTestDescriptor.
private TestDescriptorInternal createTestDescriptor(TestIdentifier test, String name, String displayName) {
TestIdentifier classIdentifier = findTestClassIdentifier(test);
String className = className(classIdentifier);
String classDisplayName = classDisplayName(classIdentifier);
return new DefaultTestDescriptor(idGenerator.generateId(), className, name, classDisplayName, displayName);
}
use of org.junit.platform.launcher.TestIdentifier in project junit5 by junit-team.
the class OverloadedTestMethodTests method executeTestCaseWithOverloadedMethodsAndThenRerunOnlyOneOfTheMethodsSelectedByUniqueId.
@Test
void executeTestCaseWithOverloadedMethodsAndThenRerunOnlyOneOfTheMethodsSelectedByUniqueId() {
Events tests = executeTestsForClass(TestCase.class).testEvents();
tests.assertStatistics(stats -> stats.started(2).succeeded(2).failed(0));
Optional<Event> first = tests.succeeded().filter(event -> event.getTestDescriptor().getUniqueId().toString().contains(TestInfo.class.getName())).findFirst();
assertTrue(first.isPresent());
TestIdentifier testIdentifier = TestIdentifier.from(first.get().getTestDescriptor());
String uniqueId = testIdentifier.getUniqueId();
tests = executeTests(selectUniqueId(uniqueId)).testEvents();
tests.assertStatistics(stats -> stats.started(1).succeeded(1).failed(0));
first = tests.succeeded().filter(event -> event.getTestDescriptor().getUniqueId().toString().contains(TestInfo.class.getName())).findFirst();
assertTrue(first.isPresent());
}
use of org.junit.platform.launcher.TestIdentifier in project junit5 by junit-team.
the class VintageLauncherIntegrationTests method execute.
private Map<TestIdentifier, TestExecutionResult> execute(LauncherDiscoveryRequestBuilder requestBuilder) {
Map<TestIdentifier, TestExecutionResult> results = new LinkedHashMap<>();
var request = toRequest(requestBuilder);
var launcher = LauncherFactory.create();
launcher.execute(request, new TestExecutionListener() {
@Override
public void executionFinished(TestIdentifier testIdentifier, TestExecutionResult testExecutionResult) {
results.put(testIdentifier, testExecutionResult);
}
});
return results;
}
Aggregations