olamy commented on issue #2795:
URL: 
https://github.com/apache/maven-surefire/issues/2795#issuecomment-6656465482

   Reopening this one, sorry @arturobernalg — your test was spot on, but it 
turns
   out it covered the one variant that already works.
   
   In the description `sample-api` has no `src/test` at all, so 
`target/test-classes`
   never gets created and surefire's early "No tests to run." check catches it. 
That
   path has been fine for a while. The problem shows up as soon as that 
directory
   exists but holds nothing runnable.
   
   I put together a 4-module reactor and ran `mvn test 
-DexcludedGroups=SlowTest`
   with surefire 3.6.1:
   
   | module | what's in target/test-classes | result |
   | --- | --- | --- |
   | mod-none | nothing, no src/test at all | passes |
   | mod-resources | one copied .properties, no .class files | **fails** |
   | mod-helpers | a test helper class, no @Test methods | **fails** |
   | mod-impl | a real JUnit 4 test | passes |
   
   Both failures give the same message:
   
   ```
   groups/excludedGroups are specified but JUnit version on classpath is too 
old to
   support groups. Check your dependency:tree to see if your project is picking 
up
   an old junit version
   ```
   
   `mod-resources` is the common one in real builds: a module with only
   `src/test/resources` still gets a `target/test-classes` directory, which is
   enough to trip the check. `mod-helpers` is the case from #2424 — shared 
matchers
   or fixtures in `src/test/java` that get published as a test-jar, with no test
   framework needed in that module.
   
   `git diff surefire-3.6.1..master` shows no changes to this code path, so 
master
   behaves the same.
   
   The root cause is ordering: `warnIfDefunctGroupsCombinations()` runs inside
   `verifyParameters()`, which only checks whether `testClassesDirectory` 
exists.
   The real test scan happens afterwards. If the groups check moved to after the
   scan, and only ran when the scan actually found tests, both cases would sort
   themselves out and a genuine misconfiguration would still fail loudly.
   
   PR #3528 helps with `mod-resources` but not `mod-helpers`, since it looks 
for any
   `.class` file rather than for actual tests.
   
   Happy to take this on.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to