由于配置错误 pom.xml 导致空白 Allure 报告

Blank Allure report due to misconfigured pom.xml

我正在尝试使用 Allure - 框架为我的 Rest Assured 测试生成报告。我 运行 使用 mvn test -Dtest=${MyClass} 命令进行测试并且所有测试都通过,然后使用 mvn allure:report 生成报告。毕竟,我启动码头服务器 mvn jetty:run,当我导航到本地主机时,我可以看到一个完全空的报告(只有没有信息的模板)。 这似乎是一个配置错误的问题,但我做错了什么?这是我的 pom.xml:

<?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>

<groupId>com.testtask</groupId>
<artifactId>com.testtask</artifactId>
<version>1.0-SNAPSHOT</version>


<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.plugin.version>3.8.0</maven.compiler.plugin.version>
    <maven.surefire.plugin.version>3.0.0-M3</maven.surefire.plugin.version>
    <aspectj.version>1.9.3.RC1</aspectj.version>
    <jetty.maven.plugin.version>9.3.9.v20160517</jetty.maven.plugin.version>
    <allure.maven.version>2.10.0</allure.maven.version>
    <rest.assured.version>3.3.0</rest.assured.version>
    <allure.rest.assured.version>2.10.0</allure.rest.assured.version>
    <allure.testng.version>2.10.0</allure.testng.version>
    <junit.version>4.12</junit.version>
</properties>

<build>
    <pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>${maven.compiler.plugin.version}</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>

            <!--Running tests-->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>${maven.surefire.plugin.version}</version>
                <configuration>
                    <testFailureIgnore>false</testFailureIgnore>
                    <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>

            <!--Server to view the report-->
            <plugin>
                <groupId>org.eclipse.jetty</groupId>
                <artifactId>jetty-maven-plugin</artifactId>
                <version>${jetty.maven.plugin.version}</version>
                <configuration>
                    <webAppSourceDirectory>${project.build.directory}/site/allure-maven-plugin</webAppSourceDirectory>
                    <stopKey>stop</stopKey>
                    <stopPort>1234</stopPort>
                </configuration>
            </plugin>
            <plugin>
                <groupId>io.qameta.allure</groupId>
                <artifactId>allure-maven</artifactId>
                <version>${allure.maven.version}</version>
            </plugin>
        </plugins>
    </pluginManagement>
</build>

<dependencies>
    <!--Rest Assured section-->
    <dependency>
        <groupId>io.rest-assured</groupId>
        <artifactId>rest-assured</artifactId>
        <version>${rest.assured.version}</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>io.rest-assured</groupId>
        <artifactId>json-path</artifactId>
        <version>${rest.assured.version}</version>
    </dependency>
    <dependency>
        <groupId>io.rest-assured</groupId>
        <artifactId>xml-path</artifactId>
        <version>${rest.assured.version}</version>
    </dependency>
    <dependency>
        <groupId>io.rest-assured</groupId>
        <artifactId>json-schema-validator</artifactId>
        <version>${rest.assured.version}</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>io.qameta.allure</groupId>
        <artifactId>allure-rest-assured</artifactId> <!--generates attachment for allure-->
        <version>${allure.rest.assured.version}</version>
    </dependency>

    <!--Allure TestNG Dependency-->
    <dependency>
        <groupId>io.qameta.allure</groupId>
        <artifactId>allure-testng</artifactId>
        <version>${allure.testng.version}</version>
    </dependency>

    <!-- Java 6 = JAX-B Version 2.0   -->
    <!-- Java 7 = JAX-B Version 2.2.3 -->
    <!-- Java 8 = JAX-B Version 2.2.8 -->
    <dependency>
        <groupId>javax.xml.bind</groupId>
        <artifactId>jaxb-api</artifactId>
        <version>2.2.11</version>
    </dependency>
    <dependency>
        <groupId>com.sun.xml.bind</groupId>
        <artifactId>jaxb-core</artifactId>
        <version>2.2.11</version>
    </dependency>
    <dependency>
        <groupId>com.sun.xml.bind</groupId>
        <artifactId>jaxb-impl</artifactId>
        <version>2.2.11</version>
    </dependency>

    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>${junit.version}</version>
        <scope>test</scope>
    </dependency>
</dependencies>

mvn allure:report

[INFO] Scanning for projects...
[INFO]
[INFO] ---------------------< com.testtask:com.testtask >----------------------
[INFO] Building com.testtask 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- allure-maven:2.10.0:report (default-cli) @ com.testtask ---
[INFO] Allure installation directory C:\PRJ\X\PetAPI/.allure
[INFO] Try to finding out allure 2.8.1
[INFO] Generate Allure report (report) with version 2.8.1
[INFO] Generate Allure report to C:\PRJ\X\PetAPI\target\site/allure-maven-plugin
[INFO] Found results directory C:\PRJ\X\PetAPI\target\allure-results
[INFO] Can't find information about categories.
[INFO] Generate report to C:\PRJ\X\PetAPI\target\site\allure-maven-plugin
Report successfully generated to C:\PRJ\X\PetAPI\target\site\allure-maven-plugin
[INFO] Report generated successfully.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 7.631 s
[INFO] Finished at: 2019-03-16T18:48:34+04:00
[INFO] ------------------------------------------------------------------------

mvn jetty:run

...
[INFO] --- jetty-maven-plugin:9.3.9.v20160517:run (default-cli) @ com.testtask ---
[INFO] Configuring Jetty for project: com.testtask
[INFO] Webapp source directory = C:\PRJ\X\PetAPI\target\site\allure-maven-plugin
[INFO] Reload Mechanic: automatic
[INFO] Classes = C:\PRJ\X\PetAPI\target\classes
[INFO] Logging initialized @7207ms
[INFO] Context path = /
[INFO] Tmp directory = C:\PRJ\X\PetAPI\target\tmp
[INFO] Web defaults = org/eclipse/jetty/webapp/webdefault.xml
[INFO] Web overrides =  none
[INFO] web.xml file = null
[INFO] Webapp directory = C:\PRJ\X\PetAPI\target\site\allure-maven-plugin
[INFO] jetty-9.3.9.v20160517
[INFO] Started o.e.j.m.p.JettyWebAppContext@4a734c04{/,file:///C:/PRJ/X/PetAPI/target/site/allure-maven-plugin/,AVAILABLE}{file:///C:/PRJ/X/PetAPI/target/site/allure-maven-plugin/}
[INFO] Started ServerConnector@24841372{HTTP/1.1,[http/1.1]}{0.0.0.0:8080}
[INFO] Started @12047ms
[INFO] Started Jetty Server

找到解决方案:需要添加对 TestNG

的依赖
<dependency>
    <groupId>org.testng</groupId>
    <artifactId>testng</artifactId>
    <version>${testng.version}</version>
    <scope>test</scope>
</dependency>

并删除对 Junit.

的依赖
<dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    <version>${junit.version}</version>
    <scope>test</scope>
</dependency>

目前 Allure 报告已正确生成