Skip to content

Inherited tests not supported #718

Open

Description

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.

Activity

  1. GeraldNDA commented on Jun 1, 2019

    @GeraldNDA
    Author

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

  2. GeraldNDA commented on Jun 2, 2019

    @GeraldNDA
    Author
  3. GeraldNDA commented on Jul 16, 2019

    @GeraldNDA
    Author

    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

  4. jdneo commented on Jul 16, 2019

    @jdneo
    Member

    Thank you for the suggestion Gerald Aryeetey (@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!

  5. benzman81 commented on Feb 21, 2022

    @benzman81

    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.

  6. benzman81 commented on Feb 21, 2022

    @benzman81

    Btw. our test framework is TestNG.

  7. jdneo commented on Feb 22, 2022

    @jdneo
    Member

    Markus Krüger (@benzman81) Thanks for reporting.

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

  8. github-actions commented on Nov 13, 2025

    @github-actions

    Hi Gerald Aryeetey (@GeraldNDA), I'm an AI Support assistant here to help with your issue. While the team reviews your request, I wanted to provide some possible tips and documentation that might help you in the meantime.

    The Java Test extension currently doesn’t surface CodeLens on concrete subclasses that inherit tests from an abstract base. You’ll only see the Run/Debug CodeLens on the abstract superclass (which fails with InstantiationException).

    Workarounds:

    • Use the Test Explorer view (or the Java: Run All Tests / Java: Run Test commands) and select your concrete subclass there.
    • Add dummy test methods in the subclass to force CodeLens to appear on that class.

    Tracking issue:

    Other references with low confidence

    • No other relevant issues found.

    The team will respond to your issue shortly. I hope these suggestions are helpful in the meantime. If this comment helped you, please give it a 👍. If the suggestion was not helpful or incorrect, please give it a 👎. Your feedback helps us improve!

  9. XuPengfei-1020 commented on Dec 1, 2025

    @XuPengfei-1020

    Any plan to fix it?

  10. youssefoubrik commented on Feb 4, 2026

    @youssefoubrik

    This issue still exists.

    When using JUnit 5 contract tests with an abstract base test class (tests defined in the abstract class, concrete subclasses provide implementations), VS Code has no way to run all child implementations or choose which subclass to run.

    The Java Test Runner only allows running each concrete subclass manually. In IntelliJ IDEA, you can run the abstract test and select one or all subclasses, which is very useful for contract testing.

    Some UI support for “run all subclasses” or selecting child implementations would greatly improve this workflow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions