为什么我的Gradle测试重复运行? [英] Why do my Gradle tests run repeatedly?

查看:124
本文介绍了为什么我的Gradle测试重复运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



当我第一次运行它时,它会编译所有东西并运行测试。当我再次运行它而不更改任何文件时,它会再次运行测试。



根据这个帖子,Gradle应该是懒惰的defaut并且不会打扰运行测试如果没有改变。



编辑:



如果我运行 gradle重复测试,测试只在第一次运行,然后跳过。但是,如果我反复运行 gradle build ,即使所有其他任务都标记为最新,每次都会重新运行测试。

解决方案

好的,所以我得到了答案,感谢Rene提示我看看'-i'的输出......



实际上我有两个测试任务:Java测试,一个来自Java插件,另一个来自我自己的'integrationTest'。我没有提到这个问题,因为我不认为它是相关的。



事实证明,这些任务正在编写他们的输出(报告等)到同一个目录,所以Gradle基于任务的输入和输出跟踪认为某些东西已经改变,并重新运行测试。

所以下一个问题(我将单独询问)变为:我如何干净地(并且使用最少的Groovy / Gradle代码)将测试任务的两个实例完全分开。


I have a pretty standard Gradle build that's building a Java project.

When I run it for the first time, it compiles everything and runs the tests. When I run it a second time without changing any files, it runs the tests again.

According to this thread, Gradle is supposed to be lazy by defaut and not bother running tests if nothing has changed. Has the default behaviour here been changed?

EDIT:

If I run gradle test repeatedly, the tests only run the first time and are subsequently skipped. However, if I run gradle build repeatedly, the tests get re-run every time, even though all other tasks are marked as up-to-date.

解决方案

OK, so I got the answer thanks to Rene prompting me to look at the '-i' output...

I actually have 2 test tasks: the 'test' one from the Java plugin, and my own 'integrationTest' one. I didn't mention this in the question because I didn't think it was relevant.

It turns out that these tasks are writing their output (reports, etc.) to the same directory, so Gradle's task-based input and output tracking was thinking that something had changed, and re-running the tests.

So the next question (which I will ask separately) becomes: how do I cleanly (and with minimal Groovy/Gradle code) completely separate two instances of the test task.

这篇关于为什么我的Gradle测试重复运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆