Maven 使用testng提供程序在surefire中禁用junit执行

Maven 使用testng提供程序在surefire中禁用junit执行,maven,testng,surefire,Maven,Testng,Surefire,我们有一个混合的testng/junit(3和4)项目,并将maven配置为有两个surefire执行;一个用于junit,一个用于testng 我注意到,在SureFire2.15和2.16(以及2.17)之间,我们的testng提供者也开始执行一些junit测试。因此,我一直在努力想办法说服testng运行程序根本不运行junit测试(因为它显然在正确执行测试时存在问题)。根据testng文档,它应该遵守junit=false配置或相应的testng.junit系统属性。所以我一直在试图说服

我们有一个混合的testng/junit(3和4)项目,并将maven配置为有两个surefire执行;一个用于junit,一个用于testng

我注意到,在SureFire2.15和2.16(以及2.17)之间,我们的testng提供者也开始执行一些junit测试。因此,我一直在努力想办法说服testng运行程序根本不运行junit测试(因为它显然在正确执行测试时存在问题)。根据testng文档,它应该遵守junit=false配置或相应的testng.junit系统属性。所以我一直在试图说服surefire通过该配置,但运气不佳

下面是我的surefire配置,有三种不同的尝试来传入此属性。第一次执行仅执行junit(548个测试)。第二次执行执行15个testng测试(太棒了!),然后执行另外240个junit测试(不是全部)


org.apache.maven.plugins
)TestNG提供程序无法执行JUnit4测试,这在某种程度上是为了让它运行junit,除非他们似乎忘记了中的选项来禁用该行为


这里有我遗漏的东西吗?

maven surefire插件中曾经有一个bug——当存在同时包含TestNG和JUnit测试的项目时,它只执行TestNG测试。bug中有一条评论说,您可以分别使用junitArtifactName或testNgArtifactName跳过JUnit或TestNG测试。 org.apache.maven.plugins maven surefire插件 2.15 测试 测试 测试 无:无


仅供参考:

我认为这与
testng.junit
无关,而与testng无关,只需添加一点信息,说明OP为什么应该尝试此操作。您的解决方案有何帮助?好吧,这是我的知识,我知道如何定义maven surefire插件将执行哪些测试(TestNG或JUnit)。我成功地运行了类似的示例,其中我需要插件同时执行TestNG和JUnit,并且为此定义了两个执行-每个执行一个。当然,我的观点是,由于代码与文本的比率,您的帖子出现在低质量队列中,我猜,我试图教育您发布通过质量过滤器和/或不被标记的答案。哦,很抱歉我不知道那件事。我将在将来发布更多的文本。您知道您的帖子有一个链接,因此您可以添加一些文本,解释如何使用名为none:none的特定配置跳过maven中的阶段?(我不是专业用户,所以我不知道我在说什么)
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.17</version>
            <configuration>
                <includes>
                    <include>**/*Test.java</include>
                    <include>**/*Test.groovy</include>
                    <include>**/*TestSuite.java</include>
                    <include>**/*TestSuite.groovy</include>
                </includes>
            </configuration>
            <executions>
                <execution>
                    <id>default-test</id>
                    <phase>test</phase>
                    <goals>
                        <goal>test</goal>
                    </goals>
                    <configuration>
                        <testNGArtifactName>none:none</testNGArtifactName>
                        <junitArtifactName>junit:junit</junitArtifactName>
                    </configuration>
                </execution>
                <execution>
                    <id>testngonly</id>
                    <phase>test</phase>
                    <goals>
                        <goal>test</goal>
                    </goals>
                    <configuration>
                        <argLine>-Dtestng.junit=false</argLine>
                        <systemPropertyVariables>
                          <testng.junit>false</testng.junit>
                        </systemPropertyVariables>
                        <configuration>
                          <properties>
                            <property>
                              <name>junit</name>
                              <value>false</value>
                            </property>
                            <property>
                              <name>verbose</name>
                              <value>true</value>
                            </property>
                          </properties>
                        </configuration>
                        <junitArtifactName>none:none</junitArtifactName>
                        <testNGArtifactName>org.testng:testng</testNGArtifactName>
                    </configuration>
                </execution>
            </executions>
        </plugin>