【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的报告窗口

 

 

 

 

posted @ 2020-07-21 09:17  bky2020bky  阅读(1446)  评论(0编辑  收藏  举报