2

当我使用 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

我怎样才能只运行一次这个特定的测试?

4

0 回答 0