如何在gradle上只运行一个测试类 [英] How to run only one test class on gradle
本文介绍了如何在gradle上只运行一个测试类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是Gradle的新手。我使用Gradle 1.10和Ubuntu 13.
I am new to Gradle. I use Gradle 1.10 and Ubuntu 13.
我想知道是否有命令只执行一个测试类,类似于SBT中的'testonly'。
I want to know if there's any command to execute only one test class, similar to 'testonly' in SBT.
推荐答案
运行单个测试类Airborn的答案很好。
To run a single test class Airborn's answer is good.
命令行选项,在这里找到,你可以简单地做这样的事情。 / p>
With using some command line options, which found here, you can simply do something like this.
gradle test --tests org.gradle.SomeTest.someSpecificFeature
gradle test --tests *SomeTest.someSpecificFeature
gradle test --tests *SomeSpecificTest
gradle test --tests all.in.specific.package*
gradle test --tests *IntegTest
gradle test --tests *IntegTest*ui*
gradle test --tests *IntegTest.singleMethod
gradle someTestTask --tests *UiTest someOtherTestTask --tests *WebTest*ui
从版本1.10开始它支持选择测试,使用测试过滤器。例如,
From version 1.10 of gradle it supports selecting tests, using a test filter. For example,
apply plugin: 'java'
test {
filter {
//specific test method
includeTestsMatching "org.gradle.SomeTest.someSpecificFeature"
//specific test method, use wildcard for packages
includeTestsMatching "*SomeTest.someSpecificFeature"
//specific test class
includeTestsMatching "org.gradle.SomeTest"
//specific test class, wildcard for packages
includeTestsMatching "*.SomeTest"
//all classes in package, recursively
includeTestsMatching "com.gradle.tooling.*"
//all integration tests, by naming convention
includeTestsMatching "*IntegTest"
//only ui tests from integration tests, by some naming convention
includeTestsMatching "*IntegTest*ui"
}
}
这篇关于如何在gradle上只运行一个测试类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文