Repository navigation
fix: discover inherited test methods when running child classes #1940
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
Open
Vinay Kumar Maheshwaram (sudovinay01)
wants to merge
4
commits into
microsoft:main
Choose a base branch
from
sudovinay01:fix/inherited-test-methods-discovery
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
0ba0e6c
fix: discover inherited test methods when running child classes
sudovinay01 17e6b99
fix: address inherited test review feedback
sudovinay01 57344f1
fix: resolve binary inherited method parameters
sudovinay01 d44bc11
Merge branch 'main' into fix/inherited-test-methods-discovery
sudovinay01 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
13 changes: 13 additions & 0 deletions
13
java-extension/com.microsoft.java.test.plugin.test/projects/inheritance-child/.classpath
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <classpath> | ||
| <classpathentry kind="src" output="target/test-classes" path="src/test/java"> | ||
| <attributes> | ||
| <attribute name="test" value="true"/> | ||
| </attributes> | ||
| </classpathentry> | ||
| <classpathentry kind="src" path="/inheritance-parent"/> | ||
| <classpathentry kind="con" | ||
| path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17"/> | ||
| <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/5"/> | ||
| <classpathentry kind="output" path="target/test-classes"/> | ||
| </classpath> |
17 changes: 17 additions & 0 deletions
17
java-extension/com.microsoft.java.test.plugin.test/projects/inheritance-child/.project
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <projectDescription> | ||
| <name>inheritance-child</name> | ||
| <comment></comment> | ||
| <projects> | ||
| <project>inheritance-parent</project> | ||
| </projects> | ||
| <buildSpec> | ||
| <buildCommand> | ||
| <name>org.eclipse.jdt.core.javabuilder</name> | ||
| <arguments></arguments> | ||
| </buildCommand> | ||
| </buildSpec> | ||
| <natures> | ||
| <nature>org.eclipse.jdt.core.javanature</nature> | ||
| </natures> | ||
| </projectDescription> |
9 changes: 9 additions & 0 deletions
9
...st.plugin.test/projects/inheritance-child/src/test/java/example/InheritanceChildTest.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| package example; | ||
|
|
||
| import org.junit.jupiter.api.Test; | ||
|
|
||
| public class InheritanceChildTest extends InheritanceBaseTest { | ||
| @Test | ||
| void child() { | ||
| } | ||
| } |
12 changes: 12 additions & 0 deletions
12
java-extension/com.microsoft.java.test.plugin.test/projects/inheritance-junit4/.classpath
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <classpath> | ||
| <classpathentry kind="src" output="target/test-classes" path="src/test/java"> | ||
| <attributes> | ||
| <attribute name="test" value="true"/> | ||
| </attributes> | ||
| </classpathentry> | ||
| <classpathentry kind="con" | ||
| path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17"/> | ||
| <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/> | ||
| <classpathentry kind="output" path="target/test-classes"/> | ||
| </classpath> |
15 changes: 15 additions & 0 deletions
15
java-extension/com.microsoft.java.test.plugin.test/projects/inheritance-junit4/.project
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <projectDescription> | ||
| <name>inheritance-junit4</name> | ||
| <comment></comment> | ||
| <projects></projects> | ||
| <buildSpec> | ||
| <buildCommand> | ||
| <name>org.eclipse.jdt.core.javabuilder</name> | ||
| <arguments></arguments> | ||
| </buildCommand> | ||
| </buildSpec> | ||
| <natures> | ||
| <nature>org.eclipse.jdt.core.javanature</nature> | ||
| </natures> | ||
| </projectDescription> |
9 changes: 9 additions & 0 deletions
9
...va.test.plugin.test/projects/inheritance-junit4/src/test/java/example/JUnit4BaseTest.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| package example; | ||
|
|
||
| import org.junit.Test; | ||
|
|
||
| public class JUnit4BaseTest { | ||
| @Test | ||
| public void inherited() { | ||
| } | ||
| } |
7 changes: 7 additions & 0 deletions
7
...a.test.plugin.test/projects/inheritance-junit4/src/test/java/example/JUnit4ChildTest.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| package example; | ||
|
|
||
| public class JUnit4ChildTest extends JUnit4BaseTest { | ||
| @Override | ||
| public void inherited() { | ||
| } | ||
| } |
12 changes: 12 additions & 0 deletions
12
java-extension/com.microsoft.java.test.plugin.test/projects/inheritance-parent/.classpath
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <classpath> | ||
| <classpathentry kind="src" output="target/test-classes" path="src/test/java"> | ||
| <attributes> | ||
| <attribute name="test" value="true"/> | ||
| </attributes> | ||
| </classpathentry> | ||
| <classpathentry kind="con" | ||
| path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17"/> | ||
| <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/5"/> | ||
| <classpathentry kind="output" path="target/test-classes"/> | ||
| </classpath> |
15 changes: 15 additions & 0 deletions
15
java-extension/com.microsoft.java.test.plugin.test/projects/inheritance-parent/.project
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <projectDescription> | ||
| <name>inheritance-parent</name> | ||
| <comment></comment> | ||
| <projects></projects> | ||
| <buildSpec> | ||
| <buildCommand> | ||
| <name>org.eclipse.jdt.core.javabuilder</name> | ||
| <arguments></arguments> | ||
| </buildCommand> | ||
| </buildSpec> | ||
| <natures> | ||
| <nature>org.eclipse.jdt.core.javanature</nature> | ||
| </natures> | ||
| </projectDescription> |
9 changes: 9 additions & 0 deletions
9
...st.plugin.test/projects/inheritance-parent/src/test/java/example/InheritanceBaseTest.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| package example; | ||
|
|
||
| import org.junit.jupiter.api.Test; | ||
|
|
||
| public class InheritanceBaseTest { | ||
| @Test | ||
| void base() { | ||
| } | ||
| } |
9 changes: 9 additions & 0 deletions
9
...va.test.plugin.test/projects/preview-junit/src/test/java/example/InheritanceBaseTest.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| package example; | ||
|
|
||
| import org.junit.jupiter.api.Test; | ||
|
|
||
| public class InheritanceBaseTest { | ||
| @Test | ||
| void base() { | ||
| } | ||
| } |
9 changes: 9 additions & 0 deletions
9
...a.test.plugin.test/projects/preview-junit/src/test/java/example/InheritanceChildTest.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| package example; | ||
|
|
||
| import org.junit.jupiter.api.Test; | ||
|
|
||
| public class InheritanceChildTest extends InheritanceBaseTest { | ||
| @Test | ||
| void child() { | ||
| } | ||
| } |
14 changes: 14 additions & 0 deletions
14
...est.plugin.test/projects/preview-junit/src/test/java/example/InheritanceOverrideTest.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| package example; | ||
|
|
||
| import org.junit.jupiter.api.Test; | ||
|
|
||
| public class InheritanceOverrideTest extends InheritanceBaseTest { | ||
| @Test | ||
| @Override | ||
| void base() { | ||
| } | ||
|
|
||
| @Test | ||
| void extra() { | ||
| } | ||
| } |
7 changes: 7 additions & 0 deletions
7
...test/projects/preview-junit/src/test/java/example/InheritanceUnannotatedOverrideTest.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| package example; | ||
|
|
||
| public class InheritanceUnannotatedOverrideTest extends InheritanceBaseTest { | ||
| @Override | ||
| void base() { | ||
| } | ||
| } |
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
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 getCannot 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
IMethodBindingfor 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.