Gradle execute task after test phase even if test has failed

有些话、适合烂在心里 提交于 2019-12-21 06:48:14

问题


I am using gradle as my builder. After running all of my test I want to execute additional task. If there are no test failures

test.doLast { /*my task*/ }

works fine. But if there is at least one test failure my task does not execute.

Is there a way to execute my task even if some of my test failed.


回答1:


test.doLast doesn't add a new task, but adds another task action to the test task. What you can do instead is to declare a finalizer task:

task foo(type: ...) { ... } // regular task declaration
test.finalizedBy(foo)

This way, foo will run even if test has failed, similar to a Java finally block.



来源:https://stackoverflow.com/questions/20973365/gradle-execute-task-after-test-phase-even-if-test-has-failed

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