Skip to content

[SUREFIRE-3468] Handle non-reflective JUnit Platform method sources - #3472

Open
xujiantop-crypto wants to merge 1 commit into
apache:masterfrom
xujiantop-crypto:fix/spock-excluded-groups-discovery
Open

xujiantop-crypto wants to merge 1 commit into
apache:masterfrom
xujiantop-crypto:fix/spock-excluded-groups-discovery

Conversation

@xujiantop-crypto

Copy link
Copy Markdown

Summary

  • Avoid resolving MethodSource#getJavaMethod() before checking the declaring class for JUnit 4 categories.
  • Treat method sources that only expose a Spock feature display name as having no method-level category, so <groups> and <excludedGroups> discovery can complete.
  • Add a regression test covering both include and exclude category filters with a non-reflective method source.

Fixes #3468

Verification

  • Surefire JUnit Platform provider tests: 114 tests, 0 failures, 0 errors.
  • Checkstyle: 0 violations.
  • Reproduced the Spock + JUnit 4 + <excludedGroups> scenario: fixed build ran 2 tests successfully.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The changes are fully reviewed, with no unresolved issues and appropriate regression coverage.

Pull request overview

This pull request fixes SUREFIRE-3468 by handling non-reflective JUnit Platform method sources during category filtering.

Changes:

  • Check declaring-class categories before resolving methods.
  • Ignore unresolvable method sources safely.
  • Add regression coverage for include and exclude filters.
File summaries
File Description
surefire-providers/surefire-junit-platform/src/test/java/org/apache/maven/surefire/junitplatform/JUnitPlatformProviderTest.java Adds regression coverage for both category filters.
surefire-providers/surefire-junit-platform/src/main/java/org/apache/maven/surefire/junitplatform/JUnitPlatformProvider.java Safely handles non-reflective method sources.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3.6.0 regression: Spock specs abort discovery (Tests run: 0) when <excludedGroups> is set and JUnit 4 is on the test classpath

2 participants