How to disable assert in gradle test

随声附和 提交于 2019-12-23 14:03:25

问题


I use JAVA_OPTS with disableassertions, but when gradle test is run, there are still outputs with java.lang.AssertionError. Why ?

build.gradle:

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 test output

: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

回答1:


Gradle runs tests in separate JVM(s).To set arguments for these JVMs, use:

tasks.withType(Test) {
    jvmArgs "...", "..."
}

There is a shortcut to enable or disable assertions:

tasks.withType(Test) {
    enableAssertions = false
}

For further API details, see the Gradle Build Language Reference.



来源:https://stackoverflow.com/questions/26399404/how-to-disable-assert-in-gradle-test

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!