Skip to content
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

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

Closed
boyarsky opened this issue Nov 4, 2018 · 4 comments · Fixed by #730
Closed

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

boyarsky opened this issue Nov 4, 2018 · 4 comments · Fixed by #730
Labels
Milestone

Comments

@boyarsky
Copy link

boyarsky commented Nov 4, 2018

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

@boyarsky
Copy link
Author

boyarsky commented Nov 4, 2018

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.

@jdneo
Copy link
Member

jdneo commented Jun 17, 2019

Hi @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?

@boyarsky
Copy link
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

@jdneo
Copy link
Member

jdneo commented Jun 18, 2019

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants