maven官方文檔
http://maven.apache.org/plugins/index.html
在pom.xml文件中增加testng的maven dependencies煮剧,可以選擇最新版本.可以去以下的網(wǎng)站搜索最新版本的maven庫(kù)
search.maven.org
image.png
maven給testng提供了3個(gè)插件用于擴(kuò)展:resource、compile春畔、surefire
在pom文件中引用testng.xml优质,使用surefire插件;引用compile插件可以解決編碼、編譯器版本問題
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>TestngDemo</groupId>
<artifactId>TestngDemo</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<!--解決編碼問題-->
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<!-- https://mvnrepository.com/artifact/org.testng/testng -->
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.11</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<configuration>
<verbose>true</verbose>
<!--在新的虛擬機(jī)中開啟-->
<fork>true</fork>
<compilerVersion>1.8</compilerVersion>
<encoding>utf-8</encoding>
<!--源代碼的編譯-->
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.20</version>
<configuration>
<suiteXmlFiles>
<!--可以添加多個(gè)xml文件-->
<file>testng.xml</file>
</suiteXmlFiles>
<properties>
<property>
<!--日志級(jí)別,0-10,10最詳細(xì)-->
<name>surefire.testng.verbose</name>
<value>5</value>
<!--允許并行-->
<name>suitethreadpoolsize</name>
<value>2</value>
</property>
</properties>
</configuration>
</plugin>
</plugins>
</build>
</project>
修改編碼格式回懦,使用resource插件端辱。官網(wǎng)給出兩種方案,最好的是在pom文件中增加<properties>勤家,還有一個(gè)是在<bulid><plugins><plugin><configuration><encoding>UTF-8<...
image.png