一、 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. Maven項目選擇Maven Test/Build之後,結果都會展示在控制台
第一次運作可能會慢一點,會下載下傳一些需要的庫