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

Run tests fail #561

Closed
jdneo opened this issue Jan 6, 2019 · 6 comments
Closed

Run tests fail #561

jdneo opened this issue Jan 6, 2019 · 6 comments

Comments

@jdneo
Copy link
Member

jdneo commented Jan 6, 2019

From @rdcoe in #470 (comment):

I have run into this error on one laptop but not another. Different code bases, so it may be project related, however I can successfully run the test goal using maven externally, so it's not a classpath problem. I have also confirmed that my .classpath test setup has the "test" attribute set to "true"

<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>

But when I run a test from the test explorer or from the test itself using the Run lens, an error dialog at pops up:

x Error

Source: Java Test Runner (Extension)

@jdneo
Copy link
Member Author

jdneo commented Jan 6, 2019

@rdcoe Would you mind to share a sample project which can reproduce this issue to us?

@rdcoe
Copy link

rdcoe commented Jan 8, 2019

This code resides in a private repo. I can share it with you if you can get me your public key. It's a super simple test, though:

 import org.junit.Assert;
 import org.junit.Test;

 public class MainVerticleTest
 {
    @Test
    public void testConfigFileResolverFindsFileInWorkingDirectory()
    {
        Assert.assertTrue( "not implemented", true );
    }
 }

The underlying code doesn't invoke anything, so I'm guessing that sharing the code won't help. If anything, the problem must be related to a hidden file that code uses. I've looked for logs but can't find any. Perhaps you can point me in the right direction and I can see what the underlying stacktrace looks like?

@jdneo
Copy link
Member Author

jdneo commented Jan 9, 2019

Hmm, may I ask what do you mean by the 'hidden file'? Could you see any output in the Test Runner's output channel?

@rdcoe
Copy link

rdcoe commented Jan 9, 2019

For hidden files, I'm referring to things like .classpath, .project, .factorypath, etc. In fact, one or more of those files must have been corrupt. I have a maven multi-module source tree and I went through all my projects and deleted this hidden files as well as the bin/ directories. Now when I use the test runner it works. I also now have a working PROBLEMS tab. Before I deleted those hidden files, I would see PROBLEMS but if I clicked on anything, I would see an error telling me that the is actually a directory. Sorry, can't really explain better than that. In any case, Code recreated what it needed after I manually deleted everything and then ran a Maven update (Shift-Alt-U) on all my modules. I think that creates the .factorypath file?

So, long story short, seems to now be working, so this bug can be closed. Workaround is to delete hidden files. I took a guess as to those I needed to delete but perhaps they are already documented somewhere? Not sure if that's true, as every extension might do its own thing and I saw no details about generated files as a side effect of any of the extensions I use.

@jdneo
Copy link
Member Author

jdneo commented Jan 9, 2019

@RDocE

Glad to know the problem has been solved. Those files (.classpath, .project, ...) are generated by the Java Language Server, just as you said, by some unknown reason, these files might be corrupted. Since Test Runner depends on the Java Language Server, thus it cannot work properly if something wrong happens at the Java Language Server side. The workaround is just what you have done: remove them and let the Language Server regenerate them.

@jdneo jdneo closed this as completed Jan 9, 2019
@Nukepayload2
Copy link

Ran into the same issue. I'm not using Maven, so I can't delete .classpath and .project files. My projects were created with an old version of Eclipse. My test project uses junit 4.8 .

Logs from "Language support for Java":

[Error - 2:23:01 PM] Apr 17, 2019 2:23:01 PM Problems occurred when invoking code from plug-in: "org.eclipse.jdt.ls.core".
null
java.lang.NullPointerException
	at com.microsoft.java.test.plugin.util.ProjectUtils.lambda$6(ProjectUtils.java:128)
	at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
	at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:175)
	at java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:948)
	at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
	at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
	at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)
	at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
	at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:499)
	at com.microsoft.java.test.plugin.util.ProjectUtils.getTestOutputPath(ProjectUtils.java:131)
	at com.microsoft.java.test.plugin.util.RuntimeClassPathUtils.resolveRuntimeClassPath(RuntimeClassPathUtils.java:67)
	at com.microsoft.java.test.plugin.handler.TestDelegateCommandHandler.executeCommand(TestDelegateCommandHandler.java:42)
	at org.eclipse.jdt.ls.core.internal.handlers.WorkspaceExecuteCommandHandler$1.run(WorkspaceExecuteCommandHandler.java:151)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45)
	at org.eclipse.jdt.ls.core.internal.handlers.WorkspaceExecuteCommandHandler.executeCommand(WorkspaceExecuteCommandHandler.java:141)
	at org.eclipse.jdt.ls.core.internal.handlers.JDTLanguageServer.lambda$4(JDTLanguageServer.java:419)
	at org.eclipse.jdt.ls.core.internal.handlers.JDTLanguageServer.lambda$32(JDTLanguageServer.java:803)
	at java.util.concurrent.CompletableFuture.uniApply(CompletableFuture.java:602)
	at java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:577)
	at java.util.concurrent.CompletableFuture$Completion.exec(CompletableFuture.java:443)
	at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
	at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
	at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
	at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)

[Error - 2:23:01 PM] Apr 17, 2019 2:23:01 PM Error in calling delegate command handler
null
java.lang.NullPointerException
	at com.microsoft.java.test.plugin.util.ProjectUtils.lambda$6(ProjectUtils.java:128)
	at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
	at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:175)
	at java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:948)
	at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
	at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
	at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)
	at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
	at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:499)
	at com.microsoft.java.test.plugin.util.ProjectUtils.getTestOutputPath(ProjectUtils.java:131)
	at com.microsoft.java.test.plugin.util.RuntimeClassPathUtils.resolveRuntimeClassPath(RuntimeClassPathUtils.java:67)
	at com.microsoft.java.test.plugin.handler.TestDelegateCommandHandler.executeCommand(TestDelegateCommandHandler.java:42)
	at org.eclipse.jdt.ls.core.internal.handlers.WorkspaceExecuteCommandHandler$1.run(WorkspaceExecuteCommandHandler.java:151)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45)
	at org.eclipse.jdt.ls.core.internal.handlers.WorkspaceExecuteCommandHandler.executeCommand(WorkspaceExecuteCommandHandler.java:141)
	at org.eclipse.jdt.ls.core.internal.handlers.JDTLanguageServer.lambda$4(JDTLanguageServer.java:419)
	at org.eclipse.jdt.ls.core.internal.handlers.JDTLanguageServer.lambda$32(JDTLanguageServer.java:803)
	at java.util.concurrent.CompletableFuture.uniApply(CompletableFuture.java:602)
	at java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:577)
	at java.util.concurrent.CompletableFuture$Completion.exec(CompletableFuture.java:443)
	at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
	at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
	at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
	at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)

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

3 participants