Debugging Gradle Tests: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
 
(One intermediate revision by the same user not shown)
Line 11: Line 11:
gradle --debug-jvm :my-subproject:test [--tests my.Test]
gradle --debug-jvm :my-subproject:test [--tests my.Test]
</syntaxhighlight>
</syntaxhighlight>
Gradle will suspend execution right before running tests and wait for debugger connection on port 5005.
Gradle will suspend execution right before running tests and wait for debugger connection on port 5005:
<syntaxhighlight lang='text'>
> Task :my-subproject:test
Listening for transport dt_socket at address: 5005
</syntaxhighlight>


=Debugging in IDE=
=Debugging in IDE=
Line 18: Line 22:


=TO REFACTOR=
=TO REFACTOR=
<font color=darkgray>
<font color=darkgray>
TODO:
TODO:
* For selecting specific tests for execution, see https://docs.gradle.org/current/userguide/java_testing.html#simple_name_pattern
* For selecting specific tests for execution, see https://docs.gradle.org/current/userguide/java_testing.html#simple_name_pattern
</font>
</font>
<font color=darkgray>Further research is needed:
<font color=darkgray>Further research is needed:
Start Gradle in debug mode:
Start Gradle in debug mode:
</font>
</font>
<syntaxhighlight lang='bash'>
<syntaxhighlight lang='bash'>
./gradlew --no-daemon -Dorg.gradle.debug=true :my-subproject:test
./gradlew --no-daemon -Dorg.gradle.debug=true :my-subproject:test
</syntaxhighlight>
</syntaxhighlight>
<font color=darkgray>It kept starting the daemon, in debug mode, and I could not debug the test. The default port is 5005.</font>
<font color=darkgray>It kept starting the daemon, in debug mode, and I could not debug the test. The default port is 5005.</font>
TODO: https://docs.gradle.org/current/userguide/java_testing.html#sec:debugging_java_tests
TODO: https://docs.gradle.org/current/userguide/java_testing.html#sec:debugging_java_tests
<font color=darkgray>
<font color=darkgray>
When the Gradle daemon is active, this works:
When the Gradle daemon is active, this works:
</font>
</font>

Latest revision as of 23:30, 1 June 2021

Internal

Overview

Debugging in Command Line

gradle test --debug-jvm [--tests my.Test]
gradle --debug-jvm :my-subproject:test [--tests my.Test]

Gradle will suspend execution right before running tests and wait for debugger connection on port 5005:

> Task :my-subproject:test
Listening for transport dt_socket at address: 5005

Debugging in IDE

TO REFACTOR

TODO:

Further research is needed: Start Gradle in debug mode:

./gradlew --no-daemon -Dorg.gradle.debug=true :my-subproject:test

It kept starting the daemon, in debug mode, and I could not debug the test. The default port is 5005. TODO: https://docs.gradle.org/current/userguide/java_testing.html#sec:debugging_java_tests When the Gradle daemon is active, this works: