File tree Expand file tree Collapse file tree 3 files changed +33
-4
lines changed
documentation/src/docs/asciidoc/release-notes
junit-platform-launcher/src/main/java/org/junit/platform/launcher/core
platform-tests/src/test/java/org/junit/platform/launcher/core Expand file tree Collapse file tree 3 files changed +33
-4
lines changed Original file line number Diff line number Diff line change @@ -65,6 +65,10 @@ to start reporting discovery issues.
6565 - Invalid `@BeforeSuite`/`@AfterSuite` method declarations (for example, when not
6666 `static`)
6767 - Cyclic dependencies between `@Suite` classes
68+ * Make validation of including `EngineFilters` more strict to avoid misconfiguration, for
69+ example, due to typos. Prior to this release, an exception was only thrown when _none_
70+ of a filter's included IDs matched any engine. Now, an exception is thrown if at least
71+ one included ID across all filters did not match any engine.
6872
6973
7074[[release-notes-5.13.0-M3-junit-jupiter]]
Original file line number Diff line number Diff line change 1212
1313import static java .util .stream .Collectors .joining ;
1414import static java .util .stream .Collectors .toCollection ;
15+ import static java .util .stream .Collectors .toSet ;
1516
17+ import java .util .Collection ;
1618import java .util .HashMap ;
1719import java .util .List ;
1820import java .util .Map ;
1921import java .util .Objects ;
22+ import java .util .Set ;
2023import java .util .SortedSet ;
2124import java .util .TreeSet ;
2225
@@ -69,12 +72,14 @@ private void checkNoUnmatchedIncludeFilter() {
6972 }
7073
7174 private SortedSet <String > getUnmatchedEngineIdsOfIncludeFilters () {
75+ Set <String > checkedTestEngineIds = checkedTestEngines .keySet ().stream () //
76+ .map (TestEngine ::getId ) //
77+ .collect (toSet ());
7278 return engineFilters .stream () //
7379 .filter (EngineFilter ::isIncludeFilter ) //
74- .filter (engineFilter -> checkedTestEngines .keySet ().stream () //
75- .map (engineFilter ::apply ) //
76- .noneMatch (FilterResult ::included )) //
77- .flatMap (engineFilter -> engineFilter .getEngineIds ().stream ()) //
80+ .map (EngineFilter ::getEngineIds ) //
81+ .flatMap (Collection ::stream ) //
82+ .filter (id -> !checkedTestEngineIds .contains (id )) //
7883 .collect (toCollection (TreeSet ::new ));
7984 }
8085
Original file line number Diff line number Diff line change @@ -167,6 +167,26 @@ void launcherThrowsExceptionWhenNoEngineMatchesIncludeEngineFilter(@TrackLogReco
167167 assertThat (log .stream (WARNING )).isEmpty ();
168168 }
169169
170+ @ Test
171+ void launcherThrowsExceptionWhenNoEngineMatchesIdInIncludeEngineFilter (@ TrackLogRecords LogRecordListener log ) {
172+ var engine = new DemoHierarchicalTestEngine ("first" );
173+ TestDescriptor test1 = engine .addTest ("test1" , noOp );
174+ LauncherDiscoveryRequest request = request () //
175+ .selectors (selectUniqueId (test1 .getUniqueId ())) //
176+ .filters (includeEngines ("first" , "second" )) //
177+ .build ();
178+
179+ var launcher = createLauncher (engine );
180+ var exception = assertThrows (JUnitException .class , () -> launcher .discover (request ));
181+
182+ assertThat (exception .getMessage ()) //
183+ .startsWith ("No TestEngine ID matched the following include EngineFilters: [second]." ) //
184+ .contains ("Please fix/remove the filter or add the engine." ) //
185+ .contains ("Registered TestEngines:\n - first (" ) //
186+ .endsWith ("Registered EngineFilters:\n - EngineFilter that includes engines with IDs [first, second]" );
187+ assertThat (log .stream (WARNING )).isEmpty ();
188+ }
189+
170190 @ Test
171191 void launcherWillLogWarningWhenAllEnginesWereExcluded (@ TrackLogRecords LogRecordListener log ) {
172192 var engine = new DemoHierarchicalTestEngine ("first" );
You can’t perform that action at this time.
0 commit comments