我需要在我的Java项目中使用Gradle。我正在用./gradlew test运行一些单元测试,但是异常堆栈跟踪是在一个我需要在浏览器中加载的网页上。为什么这么复杂?有没有办法让它在终端上,而不是像我玛文?
./gradlew test
erhoui1w1#
根据this page,将执行以下操作:
test { testLogging { exceptionFormat = 'full' } }
字符串这还真管用它并没有真正显示整个异常跟踪,但是(甚至更好?)它显示了它的相关部分(即与单元测试中编写的代码相关联的部分)。以上在build.gradle.kts中的等价物
build.gradle.kts
tasks.withType<Test> { useJUnitPlatform() testLogging { exceptionFormat = org.gradle.api.tasks.testing.logging.TestExceptionFormat.FULL } }
型
rjee0c152#
对于gradle(Kotlindsl),你可以这样做:
import org.gradle.api.tasks.testing.logging.TestExceptionFormat tasks { test { testLogging { events("passed", "skipped", "failed") showStackTraces = true exceptionFormat = TestExceptionFormat.FULL } } }
字符串
myzjeezk3#
以下是我在Android项目中的工作。在模块级build.gradle文件(如app/build.gradle)中添加以下行:
build.gradle
app/build.gradle
plugins { // ... } android { // ... } tasks.withType(Test) { testLogging { exceptionFormat = 'full' // Optionally do: showStackTraces = true } } dependencies { // ... }
3条答案
按热度按时间erhoui1w1#
根据this page,将执行以下操作:
字符串
这还真管用它并没有真正显示整个异常跟踪,但是(甚至更好?)它显示了它的相关部分(即与单元测试中编写的代码相关联的部分)。
以上在
build.gradle.kts
中的等价物型
rjee0c152#
对于gradle(Kotlindsl),你可以这样做:
字符串
myzjeezk3#
以下是我在Android项目中的工作。在模块级
build.gradle
文件(如app/build.gradle
)中添加以下行:字符串