Skip to content

Report discovery issues for @Suite classes #4429

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Mar 31, 2025

Conversation

marcphilipp
Copy link
Member

Overview

  • Report discovery issues for invalid @Suite classes
  • Report discovery issue for cyclic suites
  • Document and check preconditions
  • Prefix discovery issues encountered while resolving @Suite class

Issue: #242


I hereby agree to the terms of the JUnit Contributor License Agreement.


Definition of Done

@marcphilipp marcphilipp added this to the 5.13.0-M3 milestone Mar 26, 2025
@marcphilipp marcphilipp self-assigned this Mar 26, 2025
@marcphilipp marcphilipp requested a review from Copilot March 26, 2025 17:16
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

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);

@marcphilipp marcphilipp marked this pull request as ready for review March 26, 2025 17:29
@marcphilipp
Copy link
Member Author

@mpkorstanje Do you have time to take a look at this PR?

@marcphilipp
Copy link
Member Author

@mpkorstanje Thanks for your review!

@marcphilipp marcphilipp force-pushed the marc/242-suite-class-validation branch from d739292 to 5615e0b Compare March 31, 2025 11:49
@marcphilipp marcphilipp merged commit 2fea94c into main Mar 31, 2025
13 checks passed
@marcphilipp marcphilipp deleted the marc/242-suite-class-validation branch March 31, 2025 12:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants