I'm trying to migrate an Ant build script to a Gradle one and i was wondering: Is there anyway to have a test task run several times?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
This can be easikly done by subclassing the Test task class.
class StressTest extends Test {
// can be overwritten from within the task call
int times = 5
public FileTree getCandidateClassFiles() {
FileTree candidates = super.getCandidateClassFiles()
for (int i = 1; i < times; i++) {
candidates = candidates + super.getCandidateClassFiles()
}
return candidates
}
}
task stressTest(type: StressTest) {
// run test 10 times
times = 10
}
Inspired by Rene Groeschke, https://gist.github.com/breskeby/836316