maven 使用testng官网描述: http://maven.apache.org/surefire/maven-surefire-plugin/examples/testng.html
1、在pom.xml中添加如下 插件,testngxml 是你xml文件的地址
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.20</version>
<executions>
<execution>
<phase>test</phase>
</execution>
</executions>
<configuration>
<testFailureIgnore>true</testFailureIgnore>
<suiteXmlFiles>
<file>${testngxml}</file>
</suiteXmlFiles>
</configuration>
</plugin>
2、直接运行mvn test即可测试