vscode-java-test icon indicating copy to clipboard operation
vscode-java-test copied to clipboard

Inherited tests not supported

Open GeraldNDA opened this issue 5 years ago • 7 comments

Codelens appears for the abstract test class even though it cannot be run directly (IntelliJ redirects you to the classes that inherit from the abstract class instead ...)

Codelens does not appear on the classes that inherit from the abstract test class

Sidebar only runs tests in abstract class resulting in InstantiationException because it's abstract.

GeraldNDA avatar Jun 01 '19 15:06 GeraldNDA

Sample Project (with failing tests under polytests) JTestBug.zip

GeraldNDA avatar Jun 01 '19 15:06 GeraldNDA

I'm not sure if that would fix the issue for this project because the child class isn't annotated with @RunWith or @Nested ....

On Sat, Jun 1, 2019 at 12:27 PM Chandresh wrote: See #716 https://github.com/microsoft/vscode-java-test/pull/716 It will be supported in version 0.17.1

GeraldNDA avatar Jun 02 '19 02:06 GeraldNDA

After thinking about this, the Java Test Runner seems to have access to the class tree because it is able to build the explorer tree. It'd be useful to instead mark up this tree with whether or not this class has tests through the tree (and whether or not it can be run if it's abstract). Not sure if this is possible to translate codewise. If you want, I can look deeper in the code w/ some help

GeraldNDA avatar Jul 16 '19 02:07 GeraldNDA

Thank you for the suggestion @GeraldNDA.

Yes, since the Test Runner is an extension of the Java Language Server, it has the knowledge of the classes actually. It would be great if you are willing to help. Any contributions are welcome!

jdneo avatar Jul 16 '19 02:07 jdneo

Same issue here. A class "B" that inherits tests from class "A" cannot be executed, neither from explorer java projects view, nor from testing view. How are we supposed to run those tests now? Any hint or workaround? In eclipse this wasnt a problem at all.

benzman81 avatar Feb 21 '22 11:02 benzman81

Btw. our test framework is TestNG.

benzman81 avatar Feb 21 '22 11:02 benzman81

@benzman81 Thanks for reporting.

There will be some problem for TestNG in such cases. JUnit should be fine.

jdneo avatar Feb 22 '22 06:02 jdneo