Skip to content

Some tests inside static class won't run after click "Run All Tests" button #1283

Open

Description

@chenyuanmac

Environment:

OS: Windows
JDK: 11
Java Test Runner Extension: 0.31.2

Repro steps:

1.git clone : https://github.com/ZhengJun003/junit5-samples/tree/testrunner
2.Open junit5-jupiter-starter-maven with VSCode
3.Click "Run All Tests" from Test Explorer

Result:
Tests inside static class don't run.
image

Activity

  1. Preranamisra commented on Aug 21, 2021

    @Preranamisra

    Hey, can u add me as a contributor? I am working on it. Will solve this within somedays.

  2. jdneo commented on Aug 22, 2021

    @jdneo
    Member

    Preranamisra You can just raise your PR directly if you would like to, and I'll take a look then. This repo is open for any kind of contribution.

  3. jdneo commented on Sep 1, 2021

    @jdneo
    Member

    Preranamisra Is there anything I can help?

  4. cyberskycat commented on Oct 8, 2021

    @cyberskycat

    Sheng Chen (@jdneo) why the codelens disapper , in #1283 (comment)

    Environment:

    OS: Windows JDK: 11 Java Test Runner Extension: 0.31.2

    Repro steps:

    1.git clone : https://github.com/ZhengJun003/junit5-samples/tree/testrunner 2.Open junit5-jupiter-starter-maven with VSCode 3.Click "Run All Tests" from Test Explorer

    Result: Tests inside static class don't run. image

  5. jdneo commented on Oct 9, 2021

    @jdneo
    Member

    cyberskycat We adopted the new testing APIs from VS Code. It's using the left side 'testing decorations' to run tests now

  6. cyberskycat commented on Oct 9, 2021

    @cyberskycat

    cyberskycat We adopted the new testing APIs from VS Code. It's using the left side 'testing decorations' to run tests now

    ok thanks, and the wiki FAQ should update this info
    https://github.com/microsoft/vscode-java-test/wiki/FAQ

  7. github-actions commented on Nov 12, 2025

    @github-actions

    Hi chenyuanmac, 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.

    • JUnit 5 only recognizes nested test classes when they are annotated with Anutex (@nested) and defined as non-static inner classes. Static nested classes with test methods won’t be executed by the VS Code Test Runner.
    • To fix this, convert your static class into a non-static inner class and add Anutex (@nested), for example:
      class InnerClassTest {
          @Test
          void outMethod() { … }
      
          @Nested
          class InnerTest {
              @Test
              void innerMethod() { … }
          }
      }
    • Alternatively, move InnerTest to its own top-level .java file (e.g. InnerTest.java) so it’s discovered and run as a separate test class.

    Other references with low confidence:

    Related discussion

    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!

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