Don't fail the gradle build if a test is failing with the gradle-android-test-plugin

我的梦境 提交于 2019-12-05 15:09:20

问题


I set my project up to run with Robolectric and the the gradle-android-test-plugin. This all works fine and first tests are running and failing.

If a test fails this will also fail the gradle build. Is there a way to just let the build go on and write down the failing tests for evaluation in a later step?

The plan is to integrate the testing in a continuous integration server and there the build should only be unstable if a test fails.


回答1:


The correct syntax with AndroidConnectedTests is as following:

project.gradle.taskGraph.whenReady {
    connectedAndroidTest {
        ignoreFailures = true
    }
}

Now the test task is not failing the build anymore and you can pick up the failed tests with your build server to markt the build as unstable etc.




回答2:


Hmm. Well you have two options I think. One is to use

testTask.ignoreFailures = true

to not let the task fail when a test fails.

Another approach would be to run your gradle command with '--continue'. This will execute as many tasks as possible and list the failed tasks at the end and not stop after the first task has failed.



来源:https://stackoverflow.com/questions/20142486/dont-fail-the-gradle-build-if-a-test-is-failing-with-the-gradle-android-test-pl

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