use of org.junit.platform.commons.logging.LogRecordListener in project junit5 by junit-team.
the class VintageLauncherIntegrationTests method executesAllTestsForNotFilterableChildRunnerOfSuite.
@TrackLogRecords
@Test
void executesAllTestsForNotFilterableChildRunnerOfSuite(LogRecordListener logRecordListener) {
Class<?> suiteClass = JUnit4SuiteOfSuiteWithFilterableChildRunner.class;
Class<?> testClass = JUnit4TestCaseWithNotFilterableRunner.class;
LauncherDiscoveryRequestBuilder request = //
request().selectors(//
selectClass(suiteClass)).filters((PostDiscoveryFilter) descriptor -> includedIf(descriptor.getDisplayName().contains("#1")));
TestPlan testPlan = discover(request);
logRecordListener.clear();
assertThat(testPlan.getDescendants(getOnlyElement(testPlan.getRoots()))).hasSize(4);
Map<TestIdentifier, TestExecutionResult> results = execute(request);
//
assertThat(results.keySet().stream().map(TestIdentifier::getDisplayName)).containsExactlyInAnyOrder("JUnit Vintage", suiteClass.getName(), testClass.getName(), "Test #0", "Test #1");
//
assertThat(logRecordListener.stream(RunnerTestDescriptor.class, Level.WARNING).map(LogRecord::getMessage)).containsExactly(//
"Runner " + Suite.class.getName() + " (used on class " + suiteClass.getName() + ")" + " was not able to satisfy all filter requests.");
}
use of org.junit.platform.commons.logging.LogRecordListener in project junit5 by junit-team.
the class VintageLauncherIntegrationTests method executesAllTestsForNotFilterableRunner.
@TrackLogRecords
@Test
void executesAllTestsForNotFilterableRunner(LogRecordListener logRecordListener) {
Class<?> testClass = JUnit4TestCaseWithNotFilterableRunner.class;
LauncherDiscoveryRequestBuilder request = //
request().selectors(//
selectClass(testClass)).filters((PostDiscoveryFilter) descriptor -> includedIf(descriptor.getDisplayName().contains("#1")));
TestPlan testPlan = discover(request);
logRecordListener.clear();
assertThat(testPlan.getDescendants(getOnlyElement(testPlan.getRoots()))).hasSize(3);
Map<TestIdentifier, TestExecutionResult> results = execute(request);
//
assertThat(results.keySet().stream().map(TestIdentifier::getDisplayName)).containsExactlyInAnyOrder("JUnit Vintage", testClass.getName(), "Test #0", "Test #1");
//
assertThat(logRecordListener.stream(RunnerTestDescriptor.class, Level.WARNING).map(LogRecord::getMessage)).containsExactly(//
"Runner " + NotFilterableRunner.class.getName() + " (used on class " + testClass.getName() + ")" + " does not support filtering and will therefore be run completely.");
}
use of org.junit.platform.commons.logging.LogRecordListener in project junit5 by junit-team.
the class UniqueIdReaderTests method returnsDisplayNameWhenUniqueIdCannotBeRead.
@Test
void returnsDisplayNameWhenUniqueIdCannotBeRead(LogRecordListener listener) {
Description description = createTestDescription("ClassName", "methodName", "uniqueId");
assertEquals("methodName(ClassName)", description.getDisplayName());
Serializable uniqueId = new UniqueIdReader("wrongFieldName").apply(description);
assertEquals(description.getDisplayName(), uniqueId);
// @formatter:off
assertThat(listener.stream(UniqueIdReader.class, Level.WARNING).map(LogRecord::getMessage).filter(m -> m.equals("Could not read unique ID for Description; using display name instead: " + description.getDisplayName())).count()).isEqualTo(1);
// @formatter:on
}
Aggregations