Overview
The JUnit Platform currently provides no means to report warnings and errors during test discovery. Thus, malformed test cases (for example, Jupiter test methods with a non-void return type) get silently ignored which poses a severe risk for downstream projects: something that looks like a test in a pull request diff might not actually get executed. Therefore, we should introduce a mechanism to collect and report warnings and errors and use it for the Jupiter and Vintage engines. In addition, we should reach out to third-party test engine open source projects and ask them to adopt the new mechanism.
Validation errors (e.g., for invalid @BeforeEach method declarations) should not abort the entire discovery phase. Instead the discovery phase should continue, with the error tracked and reported during the execution phase.
Areas of Applicability
Proposals
- Allow engines to track errors by creating a special type of
TestDescriptor such as an AlwaysFailingTestDescriptor, DeadOnArrivalTestDescriptor, or ErrorReportingTestDescriptor.
- Tracked errors for such a corresponding
TestDescriptor could then be thrown as an exception during the execution phase instead of executing the corresponding container or test.
- Introduce a new property in
TestDescriptor that signals an error that was encountered during the discovery phase.
- Pass a reporting object from the
Launcher into each TestEngine to report errors.
Related Issues
Deliverables
Overview
The JUnit Platform currently provides no means to report warnings and errors during test discovery. Thus, malformed test cases (for example, Jupiter test methods with a non-void return type) get silently ignored which poses a severe risk for downstream projects: something that looks like a test in a pull request diff might not actually get executed. Therefore, we should introduce a mechanism to collect and report warnings and errors and use it for the Jupiter and Vintage engines. In addition, we should reach out to third-party test engine open source projects and ask them to adopt the new mechanism.
Validation errors (e.g., for invalid
@BeforeEachmethod declarations) should not abort the entire discovery phase. Instead the discovery phase should continue, with the error tracked and reported during the execution phase.Areas of Applicability
@BeforeAll,@AfterAll,@BeforeEach, and@AfterEachmethod declarations@Testand@TestTemplateon the same method)@Test,@TestFactory,@RepeatedTest, and@ParameterizedTestmethod declarations (see IsTestableMethod silently ignores @Test annotated methods that return a value #2244)@Suiteclass declarations@Nestedtest class declarations (see Improve diagnostics when Vintage test engine is missing #1223 and Abstract classes with@Nestedare not ignored / not handled properly #2717)@Nestedannotation (see Warn about missing @Nested annotations #1736)@Orderannotations on test classes and methods when class/method orderer is notOrderAnnotationProposals
TestDescriptorsuch as anAlwaysFailingTestDescriptor,DeadOnArrivalTestDescriptor, orErrorReportingTestDescriptor.TestDescriptorcould then be thrown as an exception during the execution phase instead of executing the corresponding container or test.TestDescriptorthat signals an error that was encountered during the discovery phase.Launcherinto eachTestEngineto report errors.Related Issues
@Nestedare not ignored / not handled properly #2717inner classes that are children of anabstract classare not executed despite@Nested#4125Deliverables
EngineTestKitsupport for test discovery #4393ClassTestDescriptor.@Suiteclasses #4429@SentenceFragments#4459TODO [#242]within the code base.DiscoveryIssue-reporting mechanism spockframework/spock#2145DiscoveryIssue-reporting mechanism cucumber/cucumber-jvm#2987