Report discovery issues for @Suite classes#4429
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR introduces enhanced reporting for discovery issues related to @suite classes. Key changes include:
- Reporting discovery issues for invalid suite classes and cyclic suite configurations.
- Adding precondition checks and message prefixing for discovery issues.
- Updating test cases and internal helper classes to support the new discovery issue reporting mechanism.
Reviewed Changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| platform-tests/src/test/java/org/junit/platform/suite/engine/testcases/ErroneousTestCase.java | Added test case with non-static lifecycle method to simulate erroneous behavior. |
| platform-tests/src/test/java/org/junit/platform/suite/engine/testsuites/ErroneousTestSuite.java | Introduced a suite that selects the erroneous test case. |
| platform-tests/src/test/java/org/junit/platform/suite/engine/testsuites/SuiteWithErroneousTestSuite.java | Provided a suite that includes the erroneous test suite. |
| platform-tests/src/test/java/org/junit/platform/engine/DiscoveryIssueTests.java | Added tests for the DiscoveryIssue.withMessage functionality. |
| junit-platform-suite-engine/src/main/java/org/junit/platform/suite/engine/IsSuiteClass.java | Refactored suite class eligibility checks to use combined conditions reporting issues. |
| platform-tests/src/test/java/org/junit/platform/suite/engine/SuiteEngineTests.java | Updated suite engine tests to check for proper reporting of discovery issues. |
| junit-platform-engine/src/main/java/org/junit/platform/engine/DiscoveryIssue.java | Extended the DiscoveryIssue API with a new withMessage method for message modification. |
| junit-platform-suite-engine/src/main/java/org/junit/platform/suite/engine/SuiteTestDescriptor.java | Introduced a DiscoveryIssueForwardingListener and adjusted constructor signatures for enhanced reporting. |
| junit-platform-suite-engine/src/main/java/org/junit/platform/suite/engine/DiscoverySelectorResolver.java | Modified selector resolution to inject a discovery listener and issue reporter. |
| junit-platform-suite-commons/src/main/java/org/junit/platform/suite/commons/SuiteLauncherDiscoveryRequestBuilder.java | Added a listener method to the discovery request builder. |
| junit-platform-suite-engine/src/main/java/org/junit/platform/suite/engine/ClassSelectorResolver.java | Updated to use the discovery listener and issue reporter when handling cycles. |
| platform-tests/src/test/java/org/junit/platform/suite/engine/SuiteTestDescriptorTests.java | Adjusted test construction to match updated production code requirements. |
| junit-platform-suite-engine/src/main/java/org/junit/platform/suite/engine/IsPotentialTestContainer.java | Removed unused code in favor of updated suite class checks. |
Comments suppressed due to low confidence (3)
platform-tests/src/test/java/org/junit/platform/suite/engine/SuiteEngineTests.java:142
- [nitpick] The expected error message in this test is tightly coupled to its formatting. Consider refactoring the error message formatting into a shared constant or helper method to ensure consistency with the discovery issue reporter and reduce brittleness in the tests.
var message = "@Suite class '%s' must not be private.".formatted(PrivateSuite.class.getName());
junit-platform-suite-engine/src/main/java/org/junit/platform/suite/engine/ClassSelectorResolver.java:111
- [nitpick] To improve maintainability, consider defining a constant for the cycle detection message format. This ensures consistent reporting of cycle issues across the codebase and simplifies future updates if the message needs to change.
if (containsCycle(id)) {
platform-tests/src/test/java/org/junit/platform/suite/engine/SuiteTestDescriptorTests.java:55
- [nitpick] Ensure that the mock EngineDiscoveryListener provided in this test sufficiently simulates realistic listener behavior. Additionally, consider adding tests that cover listener-related logic to match production expectations.
outputDirectoryProvider, mock(), discoveryIssueReporter);
Member
Author
|
@mpkorstanje Do you have time to take a look at this PR? |
36 tasks
mpkorstanje
reviewed
Mar 26, 2025
Member
Author
|
@mpkorstanje Thanks for your review! |
The ID of the engine the issue originated from is now used to prefix issues encountered during discovery of `@Suite` classes.
d739292 to
5615e0b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
@Suiteclasses@SuiteclassIssue: #242
I hereby agree to the terms of the JUnit Contributor License Agreement.
Definition of Done
@APIannotationsChange is documented in the User Guide and Release Noteswill be done in a later PR