Java 如何在maven中运行单个IT测试
我有一个项目,其中src/test/java/SingleIT.java中只有一个类 这不是一个单元测试,而是建立数据库、启动tomcat embedded等的IT测试 我如何在mvn的帮助下运行它 编辑: 我需要pom.xml中的maven配置来运行这个在pom中添加一个概要文件部分,将测试链接到概要文件Java 如何在maven中运行单个IT测试,java,maven,Java,Maven,我有一个项目,其中src/test/java/SingleIT.java中只有一个类 这不是一个单元测试,而是建立数据库、启动tomcat embedded等的IT测试 我如何在mvn的帮助下运行它 编辑: 我需要pom.xml中的maven配置来运行这个在pom中添加一个概要文件部分,将测试链接到概要文件 <profiles> <profile> <id>IT-Test</id> <build>
<profiles>
<profile>
<id>IT-Test</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.17</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>src/test/java/com/IT-Test.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
然后以通常的方式定义测试:
比如:
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="IT Tests" verbose="1">
<test name="IT Test">
<classes>
<class name="com.xxx.SingleIT"/>
</classes>
</test>
</suite>
现在,无论何时您想要运行您的测试-选择配置文件并运行应用程序。使用surefire运行单个测试:是否可以更轻松地只进行一次测试?我们可以跳过suiteXmlFile吗?