Skip to content

VS Code reports test status incorrectly when classname ends with IT #381

Closed

Description

@boyarsky

When using Maven, it is common to use *IT.java as the test class name to show it is an integration test. (vs an unit test). The failsafe plugin recommends this convention.

I wrote a very simple JUnit 5 integration tests class with one passing test and one failing test. In the Java editor, VS Code correctly shows a green check for the "good" test and a red check for the "bad" test. However, it shows both tests as skipped in the test reports list. It also shows zero tests as run on the bottom of the screen.
junit5-it

VS Code does behave properly if I rename my test from JeanneIT to JeanneTest. The test results and bottom bar both acknowledge the tests were run.
junit5-test

Activity

  1. boyarsky commented on Nov 4, 2018

    @boyarsky
    Author

    Note. When I saw another issue (#344) had a problem with the Maven plugin, I tried disabling that plugin. It solved #344 but not this one (#381). Mentioning so nobody wastes time going down that alley.

  2. jdneo commented on Jun 17, 2019

    @jdneo
    Member

    Hi Jeanne (@boyarsky), is the problem still occur by using the newest version of Test Runner?

    If yes, would you mind to provide a sample project with us to repro the issue?

  3. boyarsky commented on Jun 17, 2019

    @boyarsky
    Author

    It actually got worse. Now when I click "run test" on JeanneIT, it doesn't show anything in the report or the bottom bar.

    Here's a project with just the two classes in it. JeanneTest behaves as expected. JeanneIT does not. Other than the name, the files are the same.
    https://github.com/boyarsky/vs-code-test-runner-issue-381

  4. jdneo commented on Jun 18, 2019

    @jdneo
    Member

    Root Cause

    We are using Junit 5's junit-platform-console to launch the test execution. The CLI has an option to restrict the class name,

    the default pattern only includes class names that begin with "Test" or end with "Test" or "Tests".

    see here: https://github.com/junit-team/junit5/blob/master/junit-platform-console/src/main/java/org/junit/platform/console/options/AvailableOptions.java#L172-L177

    Workaround

    You can change the default value by setting a workspace setting for java.test.config

    {
        "java.test.config": {
            "args": ["--include-classname", ".*"]
        }
    }

    Open the Setting page and click Edit in settings.json

    image

    Follow-up

    If the user does not set -n or --include-classname in args, we set it to .*.
    Otherwise, we use the args that user provides.

  5. added this to the 0.18.1 milestone on Jun 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions