如何在gradle测试中禁用断言
我将JAVA_OPTS与disableassertions一起使用,但是当运行如何在gradle测试中禁用断言,gradle,assert,Gradle,Assert,我将JAVA_OPTS与disableassertions一起使用,但是当运行gradletest时,仍然有JAVA.lang.AssertionError的输出。为什么? 构建.渐变: apply plugin: 'java' apply plugin: 'eclipse' apply plugin: "groovy" dependencies { compile 'org.codehaus.groovy:groovy-all:2.3.6' // for compile gr
gradletest
时,仍然有JAVA.lang.AssertionError
的输出。为什么?
构建.渐变:
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: "groovy"
dependencies {
compile 'org.codehaus.groovy:groovy-all:2.3.6' // for compile groovy
compile "org.springframework:spring-core:3.0.5.RELEASE"
compile "org.springframework:spring-aop:3.0.5.RELEASE"
compile "org.springframework:spring-asm:3.0.5.RELEASE"
compile "org.springframework:spring-beans:3.0.5.RELEASE"
compile "org.springframework:spring-context:3.0.5.RELEASE"
compile "org.springframework:spring-expression:3.0.5.RELEASE"
compile "org.springframework:spring-jdbc:3.0.5.RELEASE"
compile "org.springframework:spring-orm:3.0.5.RELEASE"
compile "org.springframework:spring-test:3.0.5.RELEASE"
compile "junit:junit:4.+"
}
gradle测试
输出
:booking:processResources UP-TO-DATE
:booking:classes
:booking:jar
:compileJava
:compileGroovy
:processResources UP-TO-DATE
:classes
:compileTestJava UP-TO-DATE
:compileTestGroovy
:processTestResources UP-TO-DATE
:testClasses
:test
ScriptTester > testHandle FAILED
java.lang.AssertionError at ScriptTester.groovy:127
Gradle在单独的JVM中运行测试。要为这些JVM设置参数,请使用:
tasks.withType(Test) {
jvmArgs "...", "..."
}
有一个启用或禁用断言的快捷方式:
tasks.withType(Test) {
enableAssertions = false
}
有关进一步的API详细信息,请参阅。Post your gradle script.BTY,我在测试用例中使用SpringJUnit4ClassRunner。测试中是否有错误?Groovy断言与Java断言不同-您无法关闭Groovy断言。谢谢,现在已禁用断言。