Java Maven surefire testng provider运行JUnit测试,但不';不要报告结果

Java Maven surefire testng provider运行JUnit测试,但不';不要报告结果,java,unit-testing,maven,junit,testng,Java,Unit Testing,Maven,Junit,Testng,在我的项目中,我们有TestNG和JUnit(实际上是Spock)测试。因此,我们需要同时运行这两种方法,并从中获得结果。有了surefire供应商,这看起来很容易,所以我们做到了: <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId&

在我的项目中,我们有TestNG和JUnit(实际上是Spock)测试。因此,我们需要同时运行这两种方法,并从中获得结果。有了surefire供应商,这看起来很容易,所以我们做到了:

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.17</version>
            <configuration>
                <threadCount>1</threadCount>
            </configuration>
            <dependencies>
                <dependency>
                    <groupId>org.apache.maven.surefire</groupId>
                    <artifactId>surefire-testng</artifactId>
                    <version>2.17</version>
                </dependency>
                <dependency>
                    <groupId>org.apache.maven.surefire</groupId>
                    <artifactId>surefire-junit47</artifactId>
                    <version>2.17</version>
                </dependency>
            </dependencies>
        </plugin>

org.apache.maven.plugins
maven surefire插件
2.17
1.
org.apache.maven.surefire
surefire测试
2.17
org.apache.maven.surefire
surefire-junit47
2.17
然而,过了一段时间,我发现junit测试运行了两次。这并不好,因为我们有很多测试,我想限制它们运行的时间

经过一点研究,我发现,
surefiretestng
provider同时运行testng和JUnit测试。所以它看起来很简单-我删除了
surefire-junit47
provider

嗯,这也不是一个好的解决方案,因为事实证明testng提供程序运行junit测试,但不在
target/surefire reports/TEST*.xml
中提供结果。我在那里只找到了TestNG结果


是否有任何解决方案可以让测试只运行一次,并报告结果?

我使用surefire testng运行junit测试,但在同一次运行中没有任何testng测试

我使用以下方法提取报告:

**/surefire-reports/*.xml
您可以将surefire testng配置为包含或排除任何测试,或者您可以按模式排除junit测试,然后让junit47提供程序运行这些测试

surefire报告还可以配置为收集junit和/或testng报告

后来的junit测试使用注释而不是命名约定。testng似乎认识到这一点,但surefire报告的默认行为似乎只是通过命名约定收集数据

我仍然在junit测试中使用命名约定和注释(Test*/Test用于单元,IT/*IT用于集成),这使我能够更好地控制surefire和failsafe


使用命名约定将测试包括在surefire插件默认行为中,或者配置插件以运行特定测试并收集所需数据。

您是否可以使用surefire运行junit并使用failsafe运行testng?