-
Notifications
You must be signed in to change notification settings - Fork 134
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
Run/Debug code lenses don't appear #470
Comments
@joshmanderson Would you mind to share the project to us? |
@jdneo I can't do that, sorry – the project is private to my company. |
@joshmanderson Ok I understand. I'll keep my eyes on this issue and update here if I find anything. |
@joshmanderson One more question. Can you see the test explorer at the sidebar (though no test items in it), or there is no test explorer at all. I‘m wondering if the extension gets activated successfully. |
I'm having the same issue on two entirely separate machines; code lenses have stopped appearing and no tests are showing up in the Test Explorer either. |
@chrissantamaria Are you using Gradle as your building tools? |
@jdneo Forgive me, I'm not all that experienced with Java packages, but I believe I am; I'm just using the standard Java Extension Pack. Projects were created with Eclipse beforehand. |
@chrissantamaria Don't worry. Would you mind to share the content of |
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-10">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="bin"/>
</classpath> |
@jdneo Apologies for the late reply. |
I guess I got the root cause of this problem. In our implementation, we will only search for the test items in the But the implementation could not solve all the problems. A valid <?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
...
</classpath> For some unknown reason, some projects may not have |
@jdneo ...
<classpathentry kind="src" path="src/test/java" />
... to this: <classpathentry kind="src" path="src/test/java" output="build/classes/test">
<attributes>
<attribute name="test" value="true" />
</attributes>
</classpathentry> fixes the issue. Tests are now appearing in the test explorer (and can be run from there), and code lenses are appearing again (and working). |
@joshmanderson Glad to know we have a workaround now. 😄 |
This workaround definitely worked for me too. I had a project build in Eclipse that did not have "test" attributes in the classpathentry's. Adding this made the tests appear in the test explorer. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@jdneo I have tried setting Note that I am using the default |
@dampcake It would be helpful if you could share a sample project to repro the issue. This would be helpful for us to investigate what is going on? |
https://github.com/dampcake/bencode (small single module Maven sample). I have tried adding |
@dampcake I tried the first one and it works on my side. Here are some places that you may take a look: |
Still not able to enable it:
More info: Other things tried:
|
Here is the generated
|
One thing I observed is that test scope is missing in the generated file. Here is mine: <classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
</attributes>
... |
Yes and if added manually like in #470 (comment) it works, but it will not generate it with it in there. Was yours automatically generated like that? |
Yes it's automatically generated. Wired.... |
@jdneo Thanks for working this through with everyone! I'm experiencing another weird issue, related to this-- My .classpath does not by default generate the for my test sources, and my configuration is a bit complicated, so instead of a re-work I implemented this into my build.gradle:
This adds the test attribute, but at the bottom, see here: This does not work. However, if I let Eclipse do it , it generates the same xml, but with the test attribute at top, and it DOES work: |
@dampcake is your problem get resolved? If the test attribute is still not auto generated in your |
Thank you @tthorntone for reporting this. I find a potential bug in the implementation. Let's discuss it in #759 |
@jdneo it's still not working on my macbook. I just tried opening a couple projects today in Ubuntu and it's working fine there. I will try to dig in later this week and see if I can figure out what's going on. |
I am unable to see the tests in the Test Explorer. However, I can run the Maven test command as follows and that works. mvn test -f "c:\Users\xxx\Documents\xxx\Java\xxx\pom.xml" All the tests run to completion. Here is my configuration. VS Code Version: 1.39.0 (user setup) Electron: 4.2.10 Java JDK 1.8.0.221 I tried the solution in Issue 470, and it did not solve the problem. The Test Explorer is blank, and none of the CodeLens links appear in my unit tests. |
@rmgalante Any output in your output channel? Or any thing you can see in the problems panel? |
I've cloned the open source repo, gozer, at https://github.com/walmartlabs/gozer. You should be able to duplicate this problem with that open source repo. The Problem panel is empty. "No problems have been detected in the workspace so far." The output panels shows the following exception when I launch the project. It does not look relevant to the problem as it is just the FileWatcher exception. Looking for git in: C:\Program Files\Git\cmd\git.exe
I can't use VS Code if I don't have a Task Runner. I hope this can be fixed. |
I'm trying to figure out Debugging and Unit Testing for the first time. My class is using Eclipse, but I'd rather not download Eclipse if don't need to. I'm not entirely sure where to edit the classpath. I have a bunch of .java files in a folder, but there isn't any .classpath file. I have my Visual Studio extensions stored in a completely different place on my computer. I have a .java file I want to use for testing, but it's not specified as a test file as far as I know. I search for .classpath files in the File Explorer, and I found like 5 (they all look identical, I think they are for different versions of Java)
And I changed the 2nd classpathentry line to what it said above, but it didn't work and I don't really know what I'm doing |
@adeick If your project for teaching purpose and is not complicated, you can use the standalone project in VS Code Java:
See: https://code.visualstudio.com/docs/java/java-project/lib.mp4 |
I'm working in OpenAPITools/openapi-generator(latest master) repo. <?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="modules/openapi-generator/src/test/java/org/openapitools/codegen" output="build/classes/test">
<attributes>
<attribute name="test" value="true" />
</attributes>
</classpathentry>
</classpath> Also tried to add <sourceDirectory>src/main/java</sourceDirectory>
<outputDirectory>target/classes</outputDirectory>
<testSourceDirectory>modules/openapi-generator/src/test/java/org/openapitools/codegen</testSourceDirectory> Any suggestions? Java Test Runner 0.23.0 MacOS Mojave 10.14.6 VSCode Version: 1.46.0
Commit: a5d1cc28bb5da32ec67e86cc50f84c67cc690321
Date: 2020-06-10T08:59:06.977Z
Electron: 7.3.1
Chrome: 78.0.3904.130
Node.js: 12.8.1
V8: 7.8.279.23-electron.0
OS: Darwin x64 18.7.0 Java SDK $ java -version
java version "13.0.1" 2019-10-15
Java(TM) SE Runtime Environment (build 13.0.1+9)
Java HotSpot(TM) 64-Bit Server VM (build 13.0.1+9, mixed mode, sharing) |
@ybelenko I think it's because this project mixed with both Maven and Gradle, and the Java Language Server will import Gradle project by default. I tried to disable the setting |
@jdneo Thanks a lot! I've checked, it works under |
Starting about a week ago, code lenses for each test, as well as the lens for the test class as a whole, have stopped appearing. Also, no tests appear in the test explorer panel, though this may have been a pre-existing issue – I've never used the test explorer before so I can't say for sure.
Restarting or reloading vscode does not fix the problem, nor does restarting the computer, nor disabling and re-enabling the test runner code lens – or the root vscode code lens – setting (also tried disable+restart and re-enable+restart).
Project is using gradle and tests use junit. Gradle version was upgraded from
2.14.1
to3.5.1
17 days ago, but the issue has only started occurring in the last week, so I'm not sure that the gradle upgrade is relevant to the problem.Has anyone else experienced similar issues recently and does anyone have any ideas as to what might be causing the issue?
The text was updated successfully, but these errors were encountered: