Java 集成 maven + testNg+allure 让你们的测试报告起飞

众所周知 ,allure 是一个很可以,描述缺陷,link,用例等级,测试用例错误截图,截取视频的测试报告神器,下面我们来探索一二

一 。新建一个 maven 测试项目 ,testNG自行引入

二 。引入 allure 的maven 依赖

三 。执行 mvn clean test

四。 allure server {allure path}

就可以看到炫酷的多国语言的测试报告啦

附上maven 依赖

<?xml version="1.0" encoding="UTF-8"?>
<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>
    <properties>
        <aspectj.version>1.8.10</aspectj.version>
    </properties>
    <groupId>com.xuexi</groupId>
    <artifactId>TestngDemo</artifactId>
    <version>1.0-SNAPSHOT</version>
    <dependencies>
    <!--        testNG 依赖-->
        <dependency>
            <groupId>org.testng</groupId>
            <artifactId>testng</artifactId>
            <version>6.8</version>
            <scope>test</scope>
        </dependency>
        <dependency>
    <!--            allure 集成testng 依赖-->
            <groupId>io.qameta.allure</groupId>
            <artifactId>allure-testng</artifactId>
<!--            version 改成最新版配置-->
            <version>2.13.5</version>
            <scope>test</scope>
        </dependency>
    </dependencies>
<!--    Allure testNG插件官网 参考ALLure官网testNG配置-->
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.20</version>
                <configuration>
                    <argLine>
                        -javaagent:"${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar"
                    </argLine>
                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>org.aspectj</groupId>
                        <artifactId>aspectjweaver</artifactId>
                        <version>${aspectj.version}</version>
                    </dependency>
                </dependencies>
            </plugin>
            <plugin>
<!--                解决mvn的官方issue,,引入sure——fire——plugin 插件 -->
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.19.1</version>
                <configuration>
<!--                    配置test Fail 报错ignore -->
                    <testFailureIgnore>true</testFailureIgnore>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

这里分享一下遇到的一个坑:

 出现这个问题 主要是maven 自身的一个issue ,解决方案参见maven pom.xml

 这样 maven 打包就不会报错啦。

后面就可以看到漂亮的测试报告了

原文地址:https://www.cnblogs.com/Neotester/p/13411091.html