当我使用Gradle运行测试时,测试将运行多次。实际上它的运行次数与覆盖该测试的套件数量相同。
所以跑步时:
gradle test --tests com.mycompany.test.SomeTest
测试将运行3次。请参阅以下示例:
public class SomeTest {
@Test
public void test() {
System.out.println("SomeTest.test --");
}
}
@RunWith(Suite.class)
@Suite.SuiteClasses({SomeTest.class})
public class SomeSuit1 {}
@RunWith(Suite.class)
@Suite.SuiteClasses({SomeTest.class})
public class SomeSuit2 {}
输出将是:
shay$ gradle test --tests com.mycompany.test.SomeTest
Starting a Gradle Daemon, 2 busy Daemons could not be reused, use --status for details
:compileAspect UP-TO-DATE
:compileJava UP-TO-DATE
:processResources UP-TO-DATE
:classes UP-TO-DATE
:compileTestAspect
:compileTestJava
:processTestResources UP-TO-DATE
:testClasses
:test
Done cleaning report folder [reports]
com.mycompany.test.SomeSuit1 > com.mycompany.test.SomeTest.test STANDARD_OUT
SomeTest.test --
com.mycompany.test.SomeSuit2 > com.mycompany.test.SomeTest.test STANDARD_OUT
SomeTest.test --
com.mycompany.test.SomeTest > test STANDARD_OUT
SomeTest.test --
BUILD SUCCESSFUL
Total time: 20.219 secs
如何只运行一次此特定测试?