问题
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