我正在尝试将Ant构建脚本迁移到Gradle,我想知道:无论如何都要运行多次测试任务?
答案 0 :(得分:1)
通过继承Test任务类可以轻松完成。
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
}
灵感来自Rene Groeschke,https://gist.github.com/breskeby/836316