摇篮的测试阶段后,再执行任务,即使试验失败 [英] Gradle execute task after test phase even if test has failed
本文介绍了摇篮的测试阶段后,再执行任务,即使试验失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的gradle使用我的建设者。运行的所有我的测试后,我想执行其他任务。如果没有测试失败
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
不添加一个新的任务,但增加了另一个的任务行动到测试
任务。你可以做的反而是申报的终结任务的:
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)
这样,富
则即使测试
未能运行,类似于Java 最后
块。
This way, foo
will run even if test
has failed, similar to a Java finally
block.
这篇关于摇篮的测试阶段后,再执行任务,即使试验失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文