使用Gradle多次运行单个测试 [英] Running a single test several times with Gradle
本文介绍了使用Gradle多次运行单个测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图将一个Ant构建脚本迁移到Gradle一个,我想知道:是否有测试任务运行多次? 解决方案
这可以通过继承Test类任务轻松完成。
class StressTest extends Test {
//可以在任务调用中被覆盖
int times = 5
public FileTree getCandidateClassFiles(){
FileTree candidates = super.getCandidateClassFiles()
for int i = 1; i candidates = candidates + super.getCandidateClassFiles()
}
return candidates
}
}
任务stressTest(类型:StressTest){
//运行测试10次
次数= 10
}
灵感来自Rene Groeschke, https:// gist .github.com / breskeby / 836316
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?
解决方案
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
这篇关于使用Gradle多次运行单个测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文