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

Can run test from a .class file #1196

Open
MxD-js opened this issue May 9, 2021 · 7 comments
Open

Can run test from a .class file #1196

MxD-js opened this issue May 9, 2021 · 7 comments

Comments

@MxD-js
Copy link

MxD-js commented May 9, 2021

Hi,

I have a tests.jar package that has the tests included, I did not write the tests, instead the've been downloaded by maven, the pom.xml has them as dependency. I've downloaded the sources as well, however Code Lens does not provide the Run Test| Debug Test above each test case, or the test class.

Here's the video, I have a TestSuite.java that is in the tests folder and it shows the Run Test | Debug Test, but when I navigate to the Broker.class test that is part of the tests.jar, the Code Lens does not show the individual Run Test | Debug Test above each test, like shown here.
https://code.visualstudio.com/docs/java/java-testing#_rundebug-test-cases

video if it in action:

Screen.Recording.2021-05-08.at.8.02.40.PM.mov

Running vsCode 1.56 w/ all extensions latest version.

@jdneo
Copy link
Member

jdneo commented May 10, 2021

The Run Test | Debug Test code lenses will only show in the source code. The BrokerTest.class is a compiled class file, so it will not show the code lenses.

Is there any special reason that needs to run the tests from a dependency jar?

@MxD-js
Copy link
Author

MxD-js commented May 11, 2021

It is the project that I am on, the instructor packaged his tests in a distributable jar that is a dependency of the project but sources are available for download which I have downloaded, before the download the fernflower decompiler tries to decompile .class, but after download the source code appears as if it was a .java file but vscode keeps the .class extension. IntelliJ does it differently, After downloading sources it copies the source code to a .java file in a temporary location so that debug tools and etc operate the same as if the .java is part of the project.

@jdneo
Copy link
Member

jdneo commented May 11, 2021

Thanks for the information. So if I understand correctly (please correct me if I'm wrong), IntelliJ will download the source for the test cases you mentioned before. And therefore, you are kind of dealing with the source code, and run the test from the source code, is that correct?

@MxD-js
Copy link
Author

MxD-js commented May 11, 2021

precisely. see screen shot below this is after sources downloaded. The green play buttons starts the test for each individual test case, but the .java test source code comes from compiled jar.

I know this is an edge case, tests are typically not distributed in .jar's instead tests are in the test folder part of the project you are working on, I was questioning if I was missing something more than anything.

image

@jdneo
Copy link
Member

jdneo commented May 11, 2021

Ok, so far the implementation is only register the code lens on *.java files. So it is as expected.

I think the behavior of showing the content of the BrokerTest class in VS Code and IntelliJ are very similar. Only the file extension names are different from .java and .class.

So the question is whether we need to also apply it to *.class files. Personally I'm ok with that, but I would like to wait a while and see if other users also have this request.

@MxD-js
Copy link
Author

MxD-js commented May 11, 2021

Got it, is this a setting that I can change in the interim, to include *.class files also?

@jdneo
Copy link
Member

jdneo commented May 12, 2021

Unfortunately, we haven't expose this setting for now. But this could be a potential way to support this request.

@jdneo jdneo changed the title Code Lens not showing up for individual test cases. .class Can run test from a .class file Aug 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants