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

the Test Explorer is present outside java projects #793

Closed
erclu opened this issue Sep 4, 2019 · 13 comments · Fixed by #1110
Closed

the Test Explorer is present outside java projects #793

erclu opened this issue Sep 4, 2019 · 13 comments · Fixed by #1110
Labels
Milestone

Comments

@erclu
Copy link

erclu commented Sep 4, 2019

VSCode Version: 1.37.1 (system setup)
Java Test Runner Version: 0.19.0
OS: Windows_NT x64 10.0.18362

Apologies if it's a known issue, i couldn't find any similar ones.

The behavior i was expecting was for the java text explorer to be shown only in java projects (or, equivalently, after opening a java file), but on my system whenever the extension is not completely disabled the sidebar panel is visible and accessible.

This is not consistent with the behavior of other testing extensions (e.g. microsoft/vscode-python).

Might I also suggest to change the name shown in the panel from "Test Explorer" to something more java specific?

testrunner

@jdneo
Copy link
Member

jdneo commented Sep 6, 2019

Hi @erclu,

Thank you for your feedback. We have changed the explorer name in #796. For the issue that stopping test runner get activated. We will take a deep look and check if we have a solution there.

Thanks.

@tristan957
Copy link

@jdneo are there any updates on this issue since you last commented.

@jdneo
Copy link
Member

jdneo commented Nov 5, 2020

@tristan957 Not yet, we are kind of watching if there are more votes. If more votes are coming we will prioritize it.

@tristan957
Copy link

I would be interested in submitting a PR just because I find it so annoying.

Would you be able to provide guidance if I have questions?

@jdneo
Copy link
Member

jdneo commented Nov 5, 2020

@tristan957 How about hiding the icon by right-click the sidebar?

Screen Shot 2020-11-05 at 2 10 49 PM

@tristan957
Copy link

Not a good solution for me because I some times work in Java environments and I don't want to have to manually remember that kind of thing

@jdneo
Copy link
Member

jdneo commented Nov 5, 2020

I see. So instead of just hiding the explorer. I think we can have a welcome view to help new users know how to start with using the extension (or something else about guidance, to make it more useful). Meanwhile, maybe a setting can also be added to determine whether to show it or not.

I'll update here once I have a more concrete idea.

Thanks

@tristan957
Copy link

I mean I don't think it has to be a setting. The CMake Tools extension from Microsoft only activates and shows sidebar icon if there is a CMakelists.txt in your workspace. I just think this extension could do something similar like "if no java files, and no tests" don't show, or even just "if no java files".

@erclu
Copy link
Author

erclu commented Nov 6, 2020

I mean I don't think it has to be a setting. The CMake Tools extension from Microsoft only activates and shows sidebar icon if there is a CMakelists.txt in your workspace. I just think this extension could do something similar like "if no java files, and no tests" don't show, or even just "if no java files".

yeah I completely agree. I quickly searched through the vscode-python extension and it looks like they use this value in the when clause of the contributes.views.test[0].when key found in the package.json.

https://github.com/microsoft/vscode-python/blob/54dc5fe35c90b3b662def56858ff394a921a3907/package.json#L1928-L1936

the testsDiscovered clause seems to be defined and set to true in these files:

https://github.com/microsoft/vscode-python/search?q=%22testsDiscovered%27%2C+true%22

By glancing through the vscode extension documentation I believe they're using this feature specifically:

https://code.visualstudio.com/api/extension-guides/command#using-a-custom-when-clause-context

so a basic implementation of what they're doing would be imo to search for the presence of java files in the current workspace, maybe even of a "test" folder under src, which i believe is an accepted standard for the language, and if the search is successful add a custom when clause context:

vscode.commands.executeCommand('setContext', 'vscode-java-test:javaTestsDiscovered', true);

Then modify these lines

"views": {
"test": [
{
"id": "testExplorer",
"name": "Java"
}
]
},

to:

        "views": {
            "test": [
                {
                    "id": "testExplorer",
                    "name": "Java",
                    "when": "vscode-java-test:javaTestsDiscovered"
                }
            ]
        },

or something like that. Maybe the scoping "vscode-java-test" is unnecessary.

@tristan957
Copy link

@erclu do you also have https://github.com/Microsoft/vscode-java-dependency and https://github.com/Microsoft/vscode-maven installed? They also show their views all the time. Thinking about making issues there as well along the same lines,

@erclu
Copy link
Author

erclu commented Nov 6, 2020

@erclu do you also have https://github.com/Microsoft/vscode-java-dependency and https://github.com/Microsoft/vscode-maven installed? They also show their views all the time. Thinking about making issues there as well along the same lines,

I have them but tbh I usually keep all my extensions globally disabled and enable them for the workspaces they're needed in so I'm not impacted by this issue as much anymore. But yeah go ahead!

I think it may also be worth to open an issue for vscode itself to suggest they increase the visibility of that section of the documentation, because it does look like a lot of extensions do not implement this feature adequately.

@tristan957
Copy link

Yea all the extensions I have trouble with regarding this issue are actually all Microsoft-authored which is funny. I am opening all the issues against those extensions right now. Thanks for the effort you put into your previous comment. Easy to link to so that other extension maintainers can easily read how to use the feature.

@jdneo
Copy link
Member

jdneo commented Nov 30, 2020

New behavior: won't show the explorer if the extension is not activated, which will be available in the next release.

More details can be found in #1110

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.

3 participants