Skip to content

Replace usage of deprecated JUnit APIs#43

Merged
mp911de merged 2 commits intomp911de:mainfrom
marcphilipp:marc/junit-deprecations
Jul 1, 2025
Merged

Replace usage of deprecated JUnit APIs#43
mp911de merged 2 commits intomp911de:mainfrom
marcphilipp:marc/junit-deprecations

Conversation

@marcphilipp
Copy link
Contributor

  • Use JUnit's EngineTestKit for testing
  • Refactor discovery to use JUnit's EngineDiscoveryRequestResolver

This commit removes calls to deprecated JUnit APIs and adopts the
`EngineDiscoveryRequestResolver` approach to test discovery.
@marcphilipp marcphilipp force-pushed the marc/junit-deprecations branch from d3a7e9a to 844938a Compare June 30, 2025 15:39
@marcphilipp
Copy link
Contributor Author

For context, I noticed this while testing spring-modulith against a 6.0.0-SNAPSHOT version of JUnit in which some of the deprecated APIs had been deleted which caused the engine to fail.

@mp911de mp911de added this to the 0.7.0.RELEASE milestone Jul 1, 2025
@mp911de mp911de added the type: task A general task label Jul 1, 2025
@mp911de mp911de merged commit 054e054 into mp911de:main Jul 1, 2025
1 check passed
@mp911de
Copy link
Owner

mp911de commented Jul 1, 2025

🥳 Thank you for your contribution. That's merged now.

@marcphilipp
Copy link
Contributor Author

@mp911de Could you please double-check that my changes don't break anything? The tests in DiscoverySelectorResolverTests still pass but they don't seem to cover all scenarios.

@mp911de
Copy link
Owner

mp911de commented Jul 1, 2025

Checked against a few of my projects containing benchmarks. Jitpack has published new snapshots so your tests with Spring Modulith should pass now.

@marcphilipp marcphilipp deleted the marc/junit-deprecations branch July 1, 2025 08:36
@marcphilipp
Copy link
Contributor Author

marcphilipp commented Jul 1, 2025

The spring-modulith build now fails for a different reason:

org.junit.platform.commons.JUnitException: TestEngine with ID 'microbenchmark-engine' failed to execute tests
Caused by: java.lang.NoSuchMethodError: 'void org.junit.jupiter.engine.config.DefaultJupiterConfiguration.<init>(org.junit.platform.engine.ConfigurationParameters, org.junit.platform.engine.reporting.OutputDirectoryProvider)'
        at jmh.mbr.junit5.MicrobenchmarkEngine.execute(MicrobenchmarkEngine.java:52)

DefaultJupiterConfiguration is internal API, though. IIUC you're doing that to support ExecutionCondition Jupiter extensions for JMH benchmarks? I think a custom extension API would be more stable than trying to reuse the internals of Jupiter's.

@mp911de
Copy link
Owner

mp911de commented Jul 1, 2025

We're using quite a few internal APIs to reuse conditions. There has been once a ticket/thread discussion potential reuse but that didn't go anywhere because of complexity vs. benefits.

The config support makes heavy use of converters and defaulting. Such concerns aren't the core of this project yet necessary to leverage conditions. Implementing in this project bears always the risk of different defaults or different behavior leaving with the unclear choice of the lesser evil.

Chasing internal API changes seemed to be less problematic than duplicating code and following up with changes.

@mp911de mp911de modified the milestones: 0.7.0.RELEASE, 1.0.0 Aug 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: task A general task

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants