我正在尝试将 Ant 构建脚本迁移到 Gradle 脚本,我想知道:无论如何都要让测试任务运行多次?
最佳答案
这可以通过子类化测试任务类轻松完成。
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
关于testing - 使用 Gradle 多次运行单个测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20325556/