testing - 使用 Gradle 多次运行单个测试

标签 testing junit gradle

我正在尝试将 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/

相关文章:

Android gradle 构建脚本在 preDexDebug 中返回错误 137

java - 将库添加到 netbeans gradle 项目

windows - 如何在 Windows 10 触摸屏环境中测试 Web 应用程序? (browserstack 和 sauselabs 不起作用)

python - 从 Tkinter 运行线程并等待它完成

android - 如何使用 Espresso 测试 Android 应用程序已关闭

java - JUnit 不使用 Thread.sleep 测试计划的影响逻辑

java - 如何使用 JUnit、EasyMock 或 PowerMock 模拟静态最终变量

javascript - 使用 RxJS 5 debounceTime 进行 AngularJS 测试

java - 在没有电子邮件实际出去的情况下运行 Junit 电子邮件测试

android - Gradle 构建在 OSX 上的 Android Studio 旧版本和新版本上失败