Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Debug gradle test from within eclipse

Is it possible to debug a gradle test started with

gradle test

on CLI from within eclipse? Can I add the JVM args like

java -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005 ....

for remote debugging as I would do it for a normal Java program?

like image 889
NaN Avatar asked Apr 27 '15 11:04

NaN


1 Answers

Solution:

I prefer gradle test --debug-jvm. This starts the application in remote debug mode, and you can attach with any remote debugger, e.g., Eclipse, on port 5005. This does not only work for JUnit tests, but also for normal program executions, i.e., gradle run --debug-jvm.


Debugger Example - Eclipse:

In Eclipse, go on your Project -> Debug as... -> Debug Configuration -> Remote Java Application. As host set localhost, as port 5005.

Then you should be able to debug your tests.


Additional Info:

For more information see the official Gradle Java plugin doc regarding testing.

[...] can also be enabled at invocation time via the --debug-jvm task option (since Gradle 1.12).

like image 145
Markus Weninger Avatar answered Sep 21 '22 15:09

Markus Weninger