英文:
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
:
<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>
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:
<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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论