我遇到了一个场景,我必须初始化一个Testcase

@Test
public void foo() {
}

以便Maven识别我的TestFactory

@TestFactory
public Stream<DynamicTest> dynamicTestsFromStream() throws IOException{ 
...
}

经过一些研究,我发现了这个:

与@Test方法相比,@ TestFactory方法本身不是测试用例,而是测试用例的工厂 . 因此,动态测试是工厂的产物 . http://junit.org/junit5/docs/current/user-guide/#writing-tests-dynamic-tests

有没有办法强制TestFactory在我的Test类中没有任何@Test方法运行,因为这样它“假装”我的Jenkins构建过程,因为我总是有1次测试运行和1次成功测试 .

EDIT:

从cmd控制台在maven项目中运行 mvn test 时出现此问题 .

我的依赖是:

<dependency>
                    <groupId>org.junit.platform</groupId>
                    <artifactId>junit-platform-surefireprovider</artifactId>
                    <version>1.0.0-M1</version>
                    <scope>test</scope>
                </dependency>
                <dependency>
                    <groupId>org.junit.vintage</groupId>
                    <artifactId>junit-vintage-engine</artifactId>
                    <version>4.12.0-M1</version>
                    <scope>test</scope>
                </dependency>
                <dependency>
                    <groupId>org.junit.jupiter</groupId>
                    <artifactId>junit-jupiter-engine</artifactId>
                    <version>5.0.0-M1</version>
                    <scope>test</scope>
                </dependency>

SUMMARY

将我的Maven JUnit引擎升级到M3解决了这个问题 .