Repository navigation
fix: discover inherited test methods when running child classes - #1940
Vinay Kumar Maheshwaram (sudovinay01) wants to merge 3 commits into
Conversation
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
|
wenyt (@wenytang-ms) I have addressed your three review comments in commit 17e6b99, added regression coverage, and verified the Java reactor. Could you please take another look when you have a chance? |
| } | ||
|
|
||
| private String resolveMethodTestName(String handleId) throws CoreException { | ||
| private String resolveMethodTestName(String handleId, String executionClassName) throws CoreException { |
There was a problem hiding this comment.
If the base class comes from a dependency JAR, running an inherited test like base(TestInfo info) on its own fails here. getCompilationUnit() is null for a binary method, so we get Cannot get compilation unit of methodbase. Running the whole child class avoids this, but running or debugging just that method doesn't.
Could we get the parameter types from an IMethodBinding for binary methods instead of looking for source? We can leave the current source-method path as-is and keep using the child class for execution. A test with a compiled base class and a method parameter would catch this.
There was a problem hiding this comment.
Addressed in 57344f1. For parameterized JUnit 5/6 methods without a compilation unit, the launch resolver now uses ASTParser.createBindings() to obtain an IMethodBinding and formats its parameter types. The source-backed AST path remains unchanged, and the child class is still used as the execution target. Added a regression with a parent compiled to target/test-classes and a child project referencing it as a binary library; it verifies the selector example.InheritanceBinaryChildTest:base(org.junit.jupiter.api.TestInfo). The full Java reactor passes all 12 plugin tests.
Summary
When running a test class that extends a test base class, inherited
@Testmethods were not included in discovery. This could make the child-class run appear successful while silently skipping tests defined by its parent.This change discovers eligible test methods throughout the superclass hierarchy and lists inherited methods under the child test class.
Changes
Gradle source-set configuration and task behavior are unchanged.
Reproducer
https://github.com/sudovinay01/repro-java-issue
Validation
java-extension/mvnw.cmd clean verify -Declipse.p2.mirrors=falsepassed.AppMainSourceTestChildexecutes both the inherited and child-defined methods.images of issue