如何通过Gradle测试任务在我的JUnit上启用调试 [英] How to enable debug on my JUnit through Gradle test task
问题描述
启动测试时启用调试,现在我的测试任务如下所示:
test {
tasks.withType(Compile){
options.encoding ='UTF-8'
}
}
那么我应该怎么做才能启用调试?我在Eclipse中从Gradle面板运行gradle任务,而不是从控制台运行。感谢!
要调试测试,应该使用以下参数: - debug-jvm < code
$ b $ p例如: gradle test --debug-jvm
>在运行测试之前,Gradle将暂停执行,并等待端口5005上的调试器连接。
仅执行特定测试,请参阅 https://docs.gradle.org/current/userguide/java_testing.html#simple_name_pattern
I get into trouble while I try to run my JUnit test through gradle test task. While I run test in eclipse directly with Run As -> JUnit test, everything is ok, test succeeds. But through test task, test always fails. Probably some trouble with encoding of my resource txt file. So I would like to enable debug while I am launching test with gradle
in build.gradle, my test task now looks like:
test {
tasks.withType(Compile) {
options.encoding = 'UTF-8'
}
}
So what should I do for enable debug? I run gradle tasks from Gradle panel in Eclipse, not from console. Thanks!
To debug tests the following argument should be used: --debug-jvm
For example: gradle test --debug-jvm
Gradle will suspend execution right before running tests and wait for debugger connection on port 5005.
For executing only specific tests see https://docs.gradle.org/current/userguide/java_testing.html#simple_name_pattern
这篇关于如何通过Gradle测试任务在我的JUnit上启用调试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!