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

Unable to attach debugger to a unit test #59

Open
Elpaggio opened this issue Jul 9, 2021 · 1 comment
Open

Unable to attach debugger to a unit test #59

Elpaggio opened this issue Jul 9, 2021 · 1 comment

Comments

@Elpaggio
Copy link

Elpaggio commented Jul 9, 2021

Thanks a lot for a great project! I enjoy the fact that it is now possible to use VSCode to develop and especially debug Kotlin applications.

I know that currently there are no Kotlin test runner and code lens integration in VSCode like with ordinary java projects.
However I had hoped that I could use a "poor mans" workaround instead using the Gradle test task wiith the --debug-jvm option in order to attach the kotlin-debug-adapter and break on a breakpoint set in the unit test.

You can clone the demo project from here:
https://github.com/Elpaggio/kotlin-demo.git

./gradlew --info cleanTest test --debug-jvm

image

Unfortunately I receive some errors:

[INFO] main Connected to client
[INFO] async1 Attaching JVM debug session on localhost:5005
[TRACE] async1 Updating threads
[TRACE] async1 Updating breakpoints
[DEBUG] eventBus VM Event: VMStartEvent in thread main
[DEBUG] eventBus VM Event: ThreadStartEvent in thread main
[TRACE] async1 Configured debuggee listeners
[DEBUG] eventBus VM Event: ThreadStartEvent in thread /127.0.0.1:50766 to /127.0.0.1:38619 workers
[DEBUG] eventBus VM Event: ThreadStartEvent in thread /127.0.0.1:50766 to /127.0.0.1:38619 workers Thread 2
[DEBUG] eventBus VM Event: ThreadStartEvent in thread /127.0.0.1:50766 to /127.0.0.1:38619 workers Thread 3
[DEBUG] eventBus VM Event: ClassPrepareEvent in thread Test worker
[TRACE] eventBus Setting breakpoint at prepared type com.example.demo.DemoApplicationTests
[DEBUG] eventBus VM Event: ClassPrepareEvent in thread Test worker
[TRACE] eventBus Setting breakpoint at prepared type com.example.demo.DemoApplicationTests
2
[DEBUG] eventBus VM Event: [email protected]:9 in thread Test worker
[ERROR] server Internal error: java.lang.reflect.InvocationTargetException
[ERROR] java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
[ERROR] at org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.lambda$null$0(GenericEndpoint.java:67)
[ERROR] at org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.request(GenericEndpoint.java:120)
[ERROR] at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.handleRequest(RemoteEndpoint.java:261)
[ERROR] at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.consume(RemoteEndpoint.java:190)
[ERROR] at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.handleMessage(StreamMessageProducer.java:192)
[ERROR] at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.listen(StreamMessageProducer.java:94)
[ERROR] at org.eclipse.lsp4j.jsonrpc.json.ConcurrentMessageProcessor.run(ConcurrentMessageProcessor.java:99)
[ERROR] at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
[ERROR] at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
[ERROR] at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
[ERROR] at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
[ERROR] at java.base/java.lang.Thread.run(Thread.java:829)
[ERROR] Caused by: java.lang.reflect.InvocationTargetException
[ERROR] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[ERROR] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[ERROR] at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

Attaching the kotlin-debug-adapter to the Gradle run task works fine however

./gradlew run --debug-jvm

image

System information:
image

fwcd added a commit that referenced this issue May 17, 2022
Fix crashing issue because of exception when attaching tests
@weilbith
Copy link

Hey guys ✌️
Does this mean there is an easy way to just start kotlin-debug-adapter and then use gradle test —debug-jvm for easy debugging tests in a Gradle project?

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

2 participants