Jenkins+Maven+TestNG集成+ HTML測試結果+測試重跑機制

Jenkins+Maven+TestNG集成+ HTML測試結果+測試重跑機制

一、新建一個Maven工程:

pom.xml 文件配置如下:

<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>com.cheers.test</groupId>
	<artifactId>retrydemo1</artifactId>
	<version>0.0.1-SNAPSHOT</version>
	<packaging>jar</packaging>

	<name>retrydemo1</name>
	<url>http://maven.apache.org</url>

	<properties>
		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
		<maven-surefire-plugin.version>2.19.1</maven-surefire-plugin.version>
		<suiteXmlFile>testng.xml</suiteXmlFile>
	</properties>
	<dependencies>
		<dependency>
			<groupId>org.testng</groupId>
			<artifactId>testng</artifactId>
			<version>6.8</version>
			<scope>test</scope>
		</dependency>
	</dependencies>
	<build>
		<plugins>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-surefire-plugin</artifactId>
				<version>${maven-surefire-plugin.version}</version>
				<configuration>
					<suiteXmlFiles>
						<suiteXmlFile>${suiteXmlFile}</suiteXmlFile>
					</suiteXmlFiles>
				</configuration>
			</plugin>
		</plugins>
	</build>
</project>
注意: 添加testng的依賴,和maven-surefire-plugin插件,並配置 testng.xml

二、TestNG重跑機制實現,請參考 我的另一篇文章:

     testng實現用例失敗重跑[修改篇]
     本文用的testng相關的測試的cases都是直接引用 “testng實現用例失敗重跑[修改篇]” 的裏邊的,不做修改,不在此贅述。

三、Jenkins 找那個Maven相關配置:

新建一個 Jenkins 項目, maven 配置部分如下圖:


四、Jenkins發佈HTML的測試結果報告配置
Jenkins需要安裝“HTML Publisher plugin” 插件,以便在Jenkins發佈HTML的測試結果報告。 

配置如下:


五、在Jenkins 執行測試,並查看測試結果報告。


至此,Jenkins+Maven+TestNG集成+ HTML測試結果+測試重跑機制 均已實現了。


發佈了407 篇原創文章 · 獲贊 103 · 訪問量 139萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章