简体   繁体   English

如何使用gradle robolectric插件忽略测试失败?

[英]How can I ignore test failures with the gradle robolectric plugin?

I'm using the robolectric-gradle-plugin for robolectric unit tests. 我正在使用robolectric-gradle-plugin进行robolectric单元测试。 I don't want to fail a build on failed tests. 我不想在失败的测试中失败。 Is there a way in DSL or a property not to fail a test on the build similar to -DtestFailureIgnore=true on the Surefire Maven plugin? 在Surefire Maven插件中,是否有一种方法可以使DSL或属性不会在构建上失败,类似于-DtestFailureIgnore=true

I've tried: 我试过了:

robolectric {
    ignoreFailures = true
}

and

robolectric {
    ignoreFailure = true
}

and -DignoreFailure=true on the command line. 和命令行上的-DignoreFailure=true

I can't seem to find any documentation of how to do this, or any reference to ignoring tests in the source code. 我似乎无法找到任何关于如何执行此操作的文档,或者在源代码中忽略测试的任何引用。

answering very old question, so that it might help others who bump into here 回答一个非常古老的问题,以便它可以帮助其他人碰到这里

testOptions {
    unitTests.all {
        setIgnoreFailures(true)
    }
}

I would suggest not to continue building an APK if there are any failing tests. 如果有任何失败的测试,我建议不要继续构建APK。 But if you want to build an APK without testing the only way right now is to use gradle build -x test[1]. 但是如果你想在没有测试的情况下构建一个APK,现在唯一的方法就是使用gradle build -x test [1]。 This will run build and not run any tests. 这将运行构建而不运行任何测试。

[1] http://www.gradle.org/docs/current/userguide/userguide_single.html#sec:excluding_tasks_from_the_command_line [1] http://www.gradle.org/docs/current/userguide/userguide_single.html#sec:excluding_tasks_from_the_command_line

try without '=' 尝试没有'='

robolectric {
    ignoreFailures true
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM