Testng测试在升级到Sprint Boot 3和maven-surefire-plugin 3.1.0后被忽略。

huangapple go评论55阅读模式
英文:

Testng test are ignored after upgrading to Sprint Boot 3 and maven-surefire-plugin 3.1.0

问题

我有一个应用程序,以前可以使用Maven完美地执行TestNG测试,例如使用mvn clean install命令。

目前,我已经更新了应用程序,开始使用Spring Boot 3.1.0,现在测试完全被忽略了。没有测试被执行。

我正在使用maven-surefire-plugin中定义的经典的testng.xml文件:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>${maven-surefire-plugin.version}</version>
    <configuration>
        <suiteXmlFiles>
            <suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile>
        </suiteXmlFiles>
    </configuration>
</plugin>

我找到的所有解决方案都与Java类以*Test.java结尾有关,但这不适用于我,因为我正在使用TestNG套件文件。在更新之前,测试正常工作。

Spring Boot 3中发生了什么变化,导致我的测试被跳过?

英文:

I have an application that was executing TestNG tests perfectly with maven, for example, when using a mvn clean install command.

Currently I have updated the application to start using Spring Boot 3.1.0, and now the tests are completely ignored. No tests are executed.

I am using a classic testng.xml file defined on the maven-surefire-plugin:

            &lt;plugin&gt;
                &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                &lt;artifactId&gt;maven-surefire-plugin&lt;/artifactId&gt;
                &lt;version&gt;${maven-surefire-plugin.version}&lt;/version&gt;
                &lt;configuration&gt;
                    &lt;suiteXmlFiles&gt;
                        &lt;suiteXmlFile&gt;src/test/resources/testng.xml&lt;/suiteXmlFile&gt;
                    &lt;/suiteXmlFiles&gt;
                &lt;/configuration&gt;
            &lt;/plugin&gt;

All solutions I have found are related about the java classes ending on *Test.java but this is not applied as I am using the testng suite file. And before the update, the tests are working fine.

What has been changed into Spring Boot 3 to skip my tests?

答案1

得分: 1

好的,以下是翻译好的部分:

"Ok, I have found the "issue". Seems that the new versions of maven-surefire-plugin needs to include a surefire-testng extra plugin for executing it:

           <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>3.1.0</version>
                <configuration>
                    <suiteXmlFiles>
                        <suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile>
                    </suiteXmlFiles>
                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>org.apache.maven.surefire</groupId>
                        <artifactId>surefire-testng</artifactId>
                        <version>3.1.0</version>
                    </dependency>
                </dependencies>
            </plugin>

After including the dependency on the plugin, now is working fine.

英文:

Ok, I have found the "issue". Seems that the new versions of maven-surefire-plugin needs to include a surefire-testng extra plugin for executing it:

           &lt;plugin&gt;
                &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                &lt;artifactId&gt;maven-surefire-plugin&lt;/artifactId&gt;
                &lt;version&gt;3.1.0&lt;/version&gt;
                &lt;configuration&gt;
                    &lt;suiteXmlFiles&gt;
                        &lt;suiteXmlFile&gt;src/test/resources/testng.xml&lt;/suiteXmlFile&gt;
                    &lt;/suiteXmlFiles&gt;
                &lt;/configuration&gt;
                &lt;dependencies&gt;
                    &lt;dependency&gt;
                        &lt;groupId&gt;org.apache.maven.surefire&lt;/groupId&gt;
                        &lt;artifactId&gt;surefire-testng&lt;/artifactId&gt;
                        &lt;version&gt;3.1.0&lt;/version&gt;
                    &lt;/dependency&gt;
                &lt;/dependencies&gt;
            &lt;/plugin&gt;

After including the dependency on the plugin, now is working fine.

huangapple
  • 本文由 发表于 2023年6月1日 17:46:30
  • 转载请务必保留本文链接:https://go.coder-hub.com/76380624.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定