Skip to content

Conversation

@findepi
Copy link
Member

@findepi findepi commented Oct 27, 2025

Workaround for JUnit issue

tests that could be silently skipped by JUnit, are detected and test run is aborted.

Summary by Sourcery

Add a custom TestExecutionListener that scans the test plan for non-public test methods overriding superclass methods and fails early to avoid silent test skipping, and register it with JUnit’s service loader.

New Features:

  • Introduce ReportOverriddenMethods listener to detect non-public JUnit test methods that shadow overridden methods and prevent silent skips

Enhancements:

  • Register the new listener via META-INF/services for automatic discovery by JUnit

@cla-bot cla-bot bot added the cla-signed label Oct 27, 2025
@findepi findepi marked this pull request as draft October 27, 2025 11:29
@sourcery-ai

This comment was marked as resolved.

sourcery-ai[bot]

This comment was marked as resolved.

@findepi findepi marked this pull request as ready for review October 27, 2025 14:06
sourcery-ai[bot]

This comment was marked as resolved.

@findepi findepi requested a review from wendigo October 27, 2025 14:10
!Modifier.isProtected(methodSource.getJavaMethod().getModifiers())) {
List<Class<?>> declaringClasses = Stream.<Class<?>>iterate(methodSource.getJavaClass(), clazz -> clazz.getSuperclass() != null, Class::getSuperclass)
.filter(clazz ->
Arrays.stream(clazz.getDeclaredMethods())
Copy link
Contributor

Choose a reason for hiding this comment

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

can you extract these .filter body to a separate method for improved readability?

Copy link
Member Author

Choose a reason for hiding this comment

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

it's just two-liner

@findepi
Copy link
Member Author

findepi commented Oct 27, 2025

squashing

@findepi findepi force-pushed the findepi/junit-dups branch from 6e1443b to 36dfa17 Compare October 27, 2025 14:23
@wendigo wendigo force-pushed the findepi/junit-dups branch from 36dfa17 to 538c02a Compare October 30, 2025 16:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

3 participants