<dependencies>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.5.3</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.4</version>
</dependency>
<dependency>
<groupId>org.uncommons</groupId>
<artifactId>reportng</artifactId>
<version>1.1.4</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
<version>3.0</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.15</version>
<configuration>
<properties>
<property>
<name>usedefaultlisteners</name>
<value>false</value>
</property>
<property>
<!--使用reportng的 listener 生成测试报告-->
<name>listener</name>
<value>org.uncommons.reportng.HTMLReporter, org.uncommons.reportng.JUnitXMLReporter</value>
</property>
</properties>
<testFailureIgnore>true</testFailureIgnore>
<forkMode>never</forkMode>
<argLine>-Dfile.encoding=UTF-8</argLine>
<suiteXmlFiles>
<suiteXmlFile>xml/testng.xml</suiteXmlFile>
</suiteXmlFiles>
<workingDirectory>target/</workingDirectory>
</configuration>
</plugin>
</plugins>
</build>
- 可直接运行maven命令 mvn test 会自动生成测试报告,测试报告生成的结果在工程target/surefire-reports目录下
- 可以通过xml文件运行
xml文件内容
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="All Test Suite">
<listeners>
<listener class-name="org.uncommons.reportng.HTMLReporter"></listener>
<listener class-name="org.uncommons.reportng.JUnitXMLReporter"></listener>
</listeners>
<test verbose="2" preserve-order="true" name="C:/Users/Administrator/IdeaProjects/framework">
<classes>
<class name="com.jrx.po.test.login.LoginPagePOTest2"></class>
<class name="com.jrx.po.test.index.CreatePagePOTest"></class>
</classes>
</test>
</suite>
通过xml文件执行测试生成的结果在文件夹test-output目录下