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

TestSuite are not discovered, can't launch test (since end of 2018) #576

Closed
llgcode opened this issue Jan 11, 2019 · 11 comments
Closed

TestSuite are not discovered, can't launch test (since end of 2018) #576

llgcode opened this issue Jan 11, 2019 · 11 comments

Comments

@llgcode
Copy link

llgcode commented Jan 11, 2019

Hi,
I found this extension very useful, thank you.
I'm not able to see and run Junit test since enf of 2018, I was waiting an update that fix the problem, I thought I saw an issue about that but seems to be closed now.
I have a simple eclipse java project with some src(s) and lib(s) and jar(s) declared in classpath that I edit manually, it works great for compilation, launching my main(s). But since 2 month, I cannot see decoration in my tests classes and I'm not able to run it.
Is it a bug?
Do I need to declare something in a setting. I have no pattern to organize my tests, there are in some packages. The only pattern I used (not always) is that my test classes starts with JUnit....java

Please can you help ? so I can launch/debug test from vscode that is really helpful and powerful!

thanks for your help

@llgcode llgcode changed the title TestSuite are not discovered (since End of 2018) TestSuite are not discovered (since end of 2018) Jan 11, 2019
@llgcode llgcode changed the title TestSuite are not discovered (since end of 2018) TestSuite are not discovered, can't launch test (since end of 2018) Jan 11, 2019
@jdneo
Copy link
Member

jdneo commented Jan 11, 2019

Looks very similar to this issue: #470

Could you please check if the classpathentry and the test attribute?

@llgcode
Copy link
Author

llgcode commented Jan 11, 2019

You're right @jdneo
I've added an attribute test to true and it's workig now:

<classpathentry kind="src" path="src">
	<attributes><attribute name="test" value="true"/></attributes>
</classpathentry>

It could be great to add this to a check list, if no test is display.

Thanks.

@llgcode llgcode closed this as completed Jan 11, 2019
@noschang
Copy link

noschang commented Mar 2, 2021

You're right @jdneo
I've added an attribute test to true and it's workig now:

<classpathentry kind="src" path="src">
	<attributes><attribute name="test" value="true"/></attributes>
</classpathentry>

It could be great to add this to a check list, if no test is display.

Thanks.

This didn't work for me

@jdneo
Copy link
Member

jdneo commented Mar 3, 2021

@noschang What does your classpath looks like?

@noschang
Copy link

noschang commented Mar 3, 2021

@jdneo It looks exactly like this:

<?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 kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-14">
		<attributes>
			<attribute name="maven.pomderived" value="true"/>
		</attributes>
	</classpathentry>
	<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
		<attributes>
			<attribute name="maven.pomderived" value="true"/>
		</attributes>
	</classpathentry>
	<classpathentry kind="src" output="target/test-classes" path="src/test/java">
		<attributes>
			<attribute name="test" value="true"/>
			<attribute name="optional" value="true"/>
			<attribute name="maven.pomderived" value="true"/>			
		</attributes>
	</classpathentry>
	<classpathentry kind="src" path="target/generated-sources/annotations">
		<attributes>
			<attribute name="optional" value="true"/>
			<attribute name="maven.pomderived" value="true"/>
			<attribute name="ignore_optional_problems" value="true"/>
			<attribute name="m2e-apt" value="true"/>
		</attributes>
	</classpathentry>
	<classpathentry kind="src" output="target/test-classes" path="target/generated-test-sources/test-annotations">
		<attributes>
			<attribute name="optional" value="true"/>
			<attribute name="maven.pomderived" value="true"/>
			<attribute name="ignore_optional_problems" value="true"/>
			<attribute name="m2e-apt" value="true"/>
			<attribute name="test" value="true"/>
		</attributes>
	</classpathentry>
	<classpathentry kind="output" path="target/classes"/>
</classpath>

Actually it is automatically regenerated each time I open VSCode. From what I've been reading on several issues, this seems to be correct. I also tried to remove the attributes maven.pomderivedand optional but didn't work. Aaaannnddd, also tried to add this line in pom.xml:

<build>
    <testSourceDirectory>${basedir}/src/test/java</testSourceDirectory>
</build>

But nothing seems to work. I'm thinking to abandon the programmer life and become a dancer in a night club, maybe I'll have more luck. LOL

@noschang
Copy link

noschang commented Mar 3, 2021

@jdneo I also tried this:

{
    "java.test.config": {
        "name": "MyTests",
        "workingDirectory": "${workspaceFolder}"
    }
}

And this:

{
    "java.import.gradle.enabled": false,
    "java.import.maven.enabled": true
}

And tried creating a workspace and adding my folder to it, instead of opening it directly as a folder.

I've tried every possible solution suggested on several places of the Internet. No luck tho! At least I can run my application. Just can't run the tests.

Is there any chance that it is a problem with the JDK? I'm currently using adoptopenjdk-14-openj9 as the JDK for both, running the Java Extension Pack and running my application.

@jdneo
Copy link
Member

jdneo commented Mar 3, 2021

@noschang thanks for sharing. The configuration looks good to me. Would you mind to share a sample project to us? You can remove all the code which you don't want to share, just make sure that sample project can be used to reproduce the issue.

@noschang
Copy link

noschang commented Mar 4, 2021

@jdneo any Java project I try to open gives me the same results. I'm sending you a brand new project that I created using VSCode pallete command "Create Java Project". Here it is: MyProject1.zip, and the process I've followed:

1. Creating the project

Captura de tela de 2021-03-04 09-46-00

Captura de tela de 2021-03-04 09-46-17

2. Checking out that it runs flawlessly

It is detected as a Java Project and I can run the application normally

Captura de tela de 2021-03-04 09-58-31

Captura de tela de 2021-03-04 09-58-50

3. Trying to run the tests

The project is listed in the tests panel, but no test is detected. Also, no option to run the test through the editor.

Captura de tela de 2021-03-04 10-08-22

Trying to run the tests from the test panel gives an error message:

Captura de tela de 2021-03-04 10-08-31

And trying to run it from the file itself gives a friendly message:

new-Captura de tela de 2021-03-04 10-08-54

Finally, adding the folder to a workspace instead of opening it directly doesn't work also

Captura de tela de 2021-03-04 10-13-11

4. Special thanks!

Thank you very much! I appreciate your help!! I hope you can help me and everybody on community that is having the same problems.

I'm liking very much to code Java on VSCode and I'm planning to use it as my primary IDE for all projects (Java and not Java). But until I can get the tests to work I can't abandon Eclipse. :-)

@jdneo
Copy link
Member

jdneo commented Mar 5, 2021

@noschang

Tried your project on my side. It works without any problem.

image

  • Is that a symlink folder on your Linux Machine?
  • Are latest Java extensions installed?
  • The java.version is set to 14 in the project pom.xml, but it's showing JDK 11 according to the screenshot. Try right click the pom.xml and select Update Project?
  • Any errors in the server log? Trigger the command Java: Open Java Language Server Log File
  • Any errors in the Test Runner output channel? Set the setting java.test.log.level to verbose, and check the output channel
    image

@noschang
Copy link

noschang commented Mar 6, 2021

@jdneo oh my goodness!! You saved me!

Yes, based on your answer I investigated and remembered that my projects are stored inside a symlinked folder. I moved the project to a regular folder and it worked like a charm!! I didn't have to do anything! Just move the folder.

Thank you very much!!

I just wonder why this is a problem. From my point of view this should not be a issue, since the O.S. should abstract it from the programs. I got really curious now.

This is a red flag for me, if VSCode has problems with symlinks, maybe this could explain some odd problems that I have in other software too.

Here my boy! Take some cookies as an acknowledgment! You deserve!!

ezgif com-webp-to-png

@jdneo
Copy link
Member

jdneo commented Mar 8, 2021

@noschang

Good to know we found the root cause! It seems that VS Code do have some issues with the symlink, see: microsoft/vscode#74104, though I don't know the details of them. 🤔

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

No branches or pull requests

3 participants