【allure2+java+junit】allure報告生成


1.配置allure2環境

 a. 下載地址:https://github.com/allure-framework/allure2/releases/tag/2.13.5

 b. 解壓zip包,並將其bin目錄路徑配置到環境變量path中

 

 

 驗證配置是否生效:cmd窗口輸入 allure --version,出現版本號 2.13.5

 

2.配置maven環境

maven默認JDK是1.5 設置后支持1.8

 <properties>
        <aspectj.version>1.8.10</aspectj.version>
        <maven.compiler.source>8</maven.compiler.source>
        <maven.compiler.target>8</maven.compiler.target>
  </properties>

 

<dependency>
            <groupId>io.qameta.allure</groupId>
            <artifactId>allure-junit5</artifactId>
            <version>2.13.3</version>
            <scope>test</scope>
</dependency>
<dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-nop</artifactId>
            <version>1.7.2</version>
</dependency>

 

<build>
        <plugins>
            <plugin>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.22.1</version>
                <configuration>
                    <testFailureIgnore>false</testFailureIgnore>
                    <argLine>
                        -javaagent:"${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar"
                    </argLine>
                    <systemProperties>
                        <property>
                            <name>junit.jupiter.extensions.autodetection.enabled</name>
                            <value>true</value>
                        </property>
                    </systemProperties>
                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>org.junit.platform</groupId>
                        <artifactId>junit-platform-surefire-provider</artifactId>
                        <version>1.2.0</version>
                    </dependency>
                    <dependency>
                        <groupId>org.aspectj</groupId>
                        <artifactId>aspectjweaver</artifactId>
                        <version>RELEASE</version>
                    </dependency>
                </dependencies>
            </plugin>
            <plugin>
                <groupId>io.qameta.allure</groupId>
                <artifactId>allure-maven</artifactId>
                <version>2.10.0</version>
                <configuration>
                    <reportVersion>2.4.1</reportVersion>
                </configuration>
            </plugin>
        </plugins>
    </build>

 

3. 執行用例生成allure-results目錄下的測試結果數據

maven命令執行 :mvn test 生成allure-results文件夾

要單獨運行一個測試類里的用例,如 Wework_7_Thread.java,則可以運行 mvn test -Dtest=Wework_7_Thread

若只要當次執行數據,可先刪除allure-results文件夾下的文件,再執行mvn test 命令。

 

  

 

 

4.打開allure報告頁面

打開cmd窗口,進入到目錄所在路徑,輸入 allure serve allure-results ,此時會直接彈出allure的報告窗口

 

 

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM