使用maven命令运行testng.xml文件
一、testng.xml文件
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd"> <suite name="testcase" preserve-order="true" thread-count="8" parallel="classes"> <test verbose="5" preserve-order="true" name="testcase"> <groups> <define name="oc-test"> <include name="smoke"/> </define> <run> <include name="oc-test"/> </run> </groups> <packages> <package name="com.testcase.*"/> </packages> </test> </suite>
二、pom文件中build标签内增加配置
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.20.1</version> <configuration> <forkCount>0</forkCount> <testFailureIgnore>true</testFailureIgnore> <suiteXmlFiles> <suiteXmlFiles>testng.xml</suiteXmlFiles> </suiteXmlFiles> <groups>testcase</groups> </configuration> </plugin>
三、 执行mvn clean test命令
ps:
- testng.xml文件放在根目录下,要不然找不到文件目录