You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello. Thank you for your answer. No the issue is not solved.
If yo look at my original code and run mvn clean install you will see that the test is executed correctly.
The question (which actually is more an issue) is: how to launch it from vscode...
This Test can also be executed from eclipse and IntelliJ without making any change to the code.
I would like to be able to execute the test from vscode without making any change to the code.
I am well aware that usually test files are in the test folders, but it is not mandatory. here I want to have a full test module that has junit on its classpath (without the test scope), and contains all test classes in the main folder
Enable the setting java.import.generatesMetadataFilesAtProjectRoot in WORKSPACE scope.
Click Restart Now
Open the file named .classpath which you can find it at the project root. (If you cannot see it in the VS Code's file explorer, you can use system file explorer to find it.)
Find the classpathentry whose path is "src/main/java", and update it to:
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/> <------ Add this line
</attributes>
</classpathentry>
Then you should be able to see the tests in the test explorer.
your solution works for a very simple project like the one I posted, but it does not seem to work on a more complex project:
I posted a new branch: git clone https://github.com/clembo590/issues.git --branch vscode_java_tests_no_launch_multi_module
then cd issues; code . ;
open the file called AnotherIT.java
you will not find the little arrow to launch the test.
I also have a more complex project (that I cannot share) where vscode shows error and then the error disappear... and this I think connected to this issue as I never have issue with projects where I did not edit the .classpath manually.
@jdneo I think the solution would be to do like in intellij or eclipse: right click on a file and then RUN AS TEST
or automatically detect that it s a file that contains test and put a little arrow without having me to play with the classpath.
My observation is that, something wrong happened for the project mdr-backend-spring-1-test. The language features like GTD, hover, are all unavailable. This might be a reason why tests cannot be found.
Language features work fine in mdr-java-utils-test, so that we can see the test execution button in ParallelExecutionExceptionTest.
Hi. Some time have passed sorry about that... what about this suggestion: @jdneo I think the solution would be to do like in intellij or eclipse: right click on a file and then RUN AS TEST
or automatically detect that it s a file that contains test and put a little arrow without having me to play with the classpath.
Reacted by Lucas Theisen and Sylphrena Kleinsasser
Activity
jdneo commentedon Jun 9, 2022
That's because the class
RoleTypeTestis put undersrc/main/java, which is not the place to put tests.To provide more information, Maven has default paths to put source code and test code.
If you do not specify any customized paths in
pom.xml, test sources will be stored undersrc/test/javaby default.After changing the project structure to following, testing features should work then:

jdneo commentedon Jun 15, 2022
Is your problem solved?
clembo590 commentedon Jun 17, 2022
Hello. Thank you for your answer. No the issue is not solved.
If yo look at my original code and run
mvn clean installyou will see that the test is executed correctly.The question (which actually is more an issue) is: how to launch it from vscode...
This Test can also be executed from eclipse and IntelliJ without making any change to the code.
I would like to be able to execute the test from vscode without making any change to the code.
I am well aware that usually test files are in the test folders, but it is not mandatory. here I want to have a full test module that has junit on its classpath (without the test scope), and contains all test classes in the
mainfolderjdneo commentedon Jun 20, 2022
You can use the following steps as a workaround.
java.import.generatesMetadataFilesAtProjectRootin WORKSPACE scope.Restart Now.classpathwhich you can find it at the project root. (If you cannot see it in the VS Code's file explorer, you can use system file explorer to find it.)classpathentrywhose path is"src/main/java", and update it to:Then you should be able to see the tests in the test explorer.
clembo590 commentedon Jun 22, 2022
your solution works for a very simple project like the one I posted, but it does not seem to work on a more complex project:
I posted a new branch:
git clone https://github.com/clembo590/issues.git --branch vscode_java_tests_no_launch_multi_modulethen
cd issues; code . ;open the file called
AnotherIT.javayou will not find the little arrow to launch the test.
I also have a more complex project (that I cannot share) where vscode shows error and then the error disappear... and this I think connected to this issue as I never have issue with projects where I did not edit the

.classpathmanually.@jdneo I think the solution would be to do like in intellij or eclipse: right click on a file and then
RUN AS TESTor automatically detect that it s a file that contains test and put a little arrow without having me to play with the classpath.
jdneo commentedon Jun 23, 2022
My observation is that, something wrong happened for the project
mdr-backend-spring-1-test. The language features like GTD, hover, are all unavailable. This might be a reason why tests cannot be found.Language features work fine in
mdr-java-utils-test, so that we can see the test execution button inParallelExecutionExceptionTest.clembo590 commentedon Jul 29, 2022
Hi. Some time have passed sorry about that... what about this suggestion:
@jdneo I think the solution would be to do like in intellij or eclipse: right click on a file and then RUN AS TEST
or automatically detect that it s a file that contains test and put a little arrow without having me to play with the classpath.
jdneo commentedon Aug 1, 2022
Yes, some changes need to be done here to make the test inference become smarter.
Currently the extension relies on the content in .classpath, but for sure we have improvement room for that.