Skip to content

Conversation

mpkorstanje
Copy link
Contributor

@mpkorstanje mpkorstanje commented Aug 31, 2025

⚡️ What's your motivation?

It is possible to select a line in a classpath resource that does not exist. For example:

@Suite
@IncludeEngines("cucumber")
@SelectClasspathResource(value = "path/to/example.feature", line = 9001)
public class RunCucumberTest {
}

In a trivial suite this will result in an exception as no scenarios could be found. In a non-trivial suite that does discover other scenarios this error will go unnoticed.

By reporting this as a discovery issue and falling back to running the whole feature we ensure that no-tests go unexecuted while also informing the callers about this mis-configuration.

Example of the warning:

Aug 31, 2025 5:46:09 PM org.junit.platform.launcher.core.DiscoveryIssueNotifier logIssues
WARNING: TestEngine with ID 'junit-platform-suite' encountered a non-critical issue during test discovery:

(1) [WARNING] Feature file classpath:path/to/example.feature does not have a feature, rule, scenario, or example element at line 9001. Selecting the whole feature instead

🏷️ What kind of change is this?

  • 🐛 Bug fix (non-breaking change which fixes a defect)

📋 Checklist:

  • I agree to respect and uphold the Cucumber Community Code of Conduct
  • I've changed the behaviour of the code
    • I have added/updated tests to cover my changes.
  • My change requires a change to the documentation.
    • I have updated the documentation accordingly.
  • Users should know about my change
    • I have added an entry to the "Unreleased" section of the CHANGELOG, linking to this pull request.

It is possible to select a line in a classpath resource that does not
exist. For example:

```java
@suite
@IncludeEngines("cucumber")
@SelectClasspathResource(value = "path/to/example.feature", line = 9001)
public class RunCucumberTest {
}
```

In a trivial suite this will result in an exception as no scenarios
could be found. In a non-trivial suite that does discover other
scenarios this error will go unnoticed.

By reporting this as a discovery issue and falling back to running the
whole feature we ensure that no-tests go unexecuted while also informing
the callers about this mis-configuration.
@mpkorstanje mpkorstanje changed the title [JUnit Platform Engine] Warn when a selected line does not have a selectable element [JUnit Platform Engine] Warn when selected line does not exist Aug 31, 2025
@mpkorstanje mpkorstanje marked this pull request as ready for review August 31, 2025 16:05
@mpkorstanje mpkorstanje merged commit c494f5f into main Aug 31, 2025
6 checks passed
@mpkorstanje mpkorstanje deleted the junit-platform-require-line-exists branch August 31, 2025 16:06
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.

1 participant