Gradle能否以特定的顺序运行两个测试? [英] Can Gradle run two tests in a specific order?

查看:203
本文介绍了Gradle能否以特定的顺序运行两个测试?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在将一些ant构建脚本迁移到gradle,并一路诊断问题。出现的一个问题是,在CI服务器上(jenkins运行gradle),我们偶尔会遇到测试失败。我们认为这个问题与测试执行顺序有关,因为其中一个失败的测试在某些库代码中使用线程本地存储。



我希望能够重现在修复破碎的测试之前在本地问题。然而。我不能在本地重现问题,因为gradle总是按照正常工作的顺序运行测试。



那么,有没有办法强制gradle运行测试类X在测试课Y之前?测试需要在同一个JVM中运行 - 一个测试一个接一个地执行。



如果有问题,测试是JUnit测试。

$ b $每一个Peter在Gradle论坛上的回应,这是不可能的。



http://forums.gradle.org/gradle/topics / can_gradle_run_two_tests_in_a_specific_desired_order_in_the_same_jvm?utm_content = reply_link& utm_medium = email& utm_source = reply_notification#reply_13187620



另一种方法是使用测试套件。


We're migrating some ant build scripts to gradle and are diagnosing issues along the way. One problem that has popped up is that on the CI server (jenkins running gradle) we occasionally get test failures. We think the issue is related to test execution order because one of the tests that is failing uses thread local storage in some library code.

I would like to be able to reproduce the problem locally before fixing the broken tests. However. I can't reproduce the problem locally because gradle always runs the tests in an order that happens to work.

So, is there a way to force gradle to run test class X before test class Y? The tests need to run in the same JVM - one test right after the other.

In case it matters, the tests are JUnit tests.

解决方案

Per Peter's response on the gradle forum, this is not possible.

http://forums.gradle.org/gradle/topics/can_gradle_run_two_tests_in_a_specific_desired_order_in_the_same_jvm?utm_content=reply_link&utm_medium=email&utm_source=reply_notification#reply_13187620

An alternative is to use a test suite.

这篇关于Gradle能否以特定的顺序运行两个测试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆