简体   繁体   中英

Gradle execute task after test phase even if test has failed

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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