天天看點

2.13 接口自動化 ---TestNG結合allure生成測試報告一、 allure 使用基本準備:二 、 使用三、 總結

一、 allure 使用基本準備:

   1.  Allure學習位址:

            https://docs.qameta.io/allure/#_testng

  2.   allure 的 Maven坐标(pom.xml自行添入)

<dependency>
        <groupId>io.qameta.allure</groupId>
        <artifactId>allure-testng</artifactId>
        <version>LAST_VERSION</version>
        <scope>test</scope>
    </dependency>
           

  3.   導入surefire插件(pom.xml中引入插件)

<!-- maven    -surefire-plugin 配合testng執行測試用例的maven插件 -->
		    <plugin>
			<groupId>org.apache.maven.plugins</groupId>
			<artifactId>maven-surefire-plugin</artifactId>
			<version>2.22.1</version>
			<configuration>
				<!-- 測試失敗後,是否忽略并繼續測試 -->
				<testFailureIgnore>true</testFailureIgnore>
				<suiteXmlFiles>
					<!-- testng配置檔案名稱  -->
					<suiteXmlFile>testng.xml</suiteXmlFile>
				</suiteXmlFiles>
				<!--設定參數指令行 -->
				<argLine>
					<!-- UTF-8編碼 -->
					-Dfile.encoding=UTF-8
					<!-- 配置攔截器 -->
					-javaagent:"${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar"
				</argLine>
				<systemProperties>
					<property>
						<!-- 配置 allure 結果存儲路徑  -->
						<name>allure.results.directory</name>
						<value>${project.build.directory}/allure-results</value>
					</property>
				</systemProperties>
			</configuration>
			<dependencies>
				<!-- aspectjweaver maven坐标 -->
				<dependency>
					<groupId>org.aspectj</groupId>
					<artifactId>aspectjweaver</artifactId>
					<version>${aspectj.version}</version>
				</dependency>
			</dependencies>
		</plugin>
           

  4. pom.xml 中properties中間增加一行:

<aspectj.version>1.9.2</aspectj.version>   
           

二 、 使用

 1.   maven運作(步驟) 

滑鼠定位項目 --->  滑鼠右鍵 ---->Run ----->maven-build...  進入如下界面 ----> Goal 輸入 clean test ----->最後“Run”

2.13 接口自動化 ---TestNG結合allure生成測試報告一、 allure 使用基本準備:二 、 使用三、 總結

2.  Maven項目選擇Maven Test/Build之後,結果都會展示在控制台

   第一次運作可能會慢一點,會下載下傳一些需要的庫

2.13 接口自動化 ---TestNG結合allure生成測試報告一、 allure 使用基本準備:二 、 使用三、 總結
2.13 接口自動化 ---TestNG結合allure生成測試報告一、 allure 使用基本準備:二 、 使用三、 總結

3. Build之後, Malven項目下會存在一個target目錄

2.13 接口自動化 ---TestNG結合allure生成測試報告一、 allure 使用基本準備:二 、 使用三、 總結

4.   指令啟動 allure 内置服務: io.qameta.allure:allure-maven:serve

2.13 接口自動化 ---TestNG結合allure生成測試報告一、 allure 使用基本準備:二 、 使用三、 總結

5. 步驟4執行完成之後,會自動浏覽器打開,顯示本次test結果報告

2.13 接口自動化 ---TestNG結合allure生成測試報告一、 allure 使用基本準備:二 、 使用三、 總結

2.13 接口自動化 ---TestNG結合allure生成測試報告一、 allure 使用基本準備:二 、 使用三、 總結

三、 總結

2.13 接口自動化 ---TestNG結合allure生成測試報告一、 allure 使用基本準備:二 、 使用三、 總結