无法生成诱惑报告

Unable to generate allure reports

mvn 站点总是在 /target 目录中寻找 allure-results。但是在我的项目基目录中生成了 allure-results 目录。

  1. 如何在不同的目录中生成 allure-results。
  2. 如何让 mvn 站点从不同目录引用 allure-results?

我正在使用 allure 2,下面是我的 pom 文件配置。

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <cucumber.version>1.2.5</cucumber.version>
    <extentreports.version>3.0.6</extentreports.version>
    <spring.version>4.1.5.RELEASE</spring.version>
    <selenium.version>3.4.0</selenium.version>
    <testng.version>6.10</testng.version>
    <aspectj.version>1.8.10</aspectj.version>
    <allure.results.directory>allure-results</allure.results.directory>
        <allure.report.directory>${basedir}\test-output\allure-report</allure.report.directory>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <allure.results_pattern>allure-results</allure.results_pattern>
</properties>


....
 <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.21.0</version>
                <configuration>
                    <suiteXmlFiles>
                        <suiteXmlFile>TestNG.xml</suiteXmlFile>
                    </suiteXmlFiles>
                    <argLine>
                        -javaagent:"${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar"
                    </argLine>
                    <systemProperties>
                    <property>
                        <name>allure.results.directory</name>
                        <value>${allure.results.directory}</value>
                    </property>
                </systemProperties>
<!--                 <resultsDirectory>${allure.results.directory}</resultsDirectory> -->
<!--                 <reportsDirectory>${allure.report.directory}</reportsDirectory> -->
                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>org.aspectj</groupId>
                        <artifactId>aspectjweaver</artifactId>
                        <version>${aspectj.version}</version>
                    </dependency>
                </dependencies>
        </plugin>

        .... 

        <dependency>
             <groupId>io.qameta.allure</groupId>
             <artifactId>allure-testng</artifactId>
             <version>2.6.0</version>
    </dependency>


    ....


        <reporting>
        <excludeDefaults>true</excludeDefaults>
        <plugins>
            <plugin>
                <groupId>io.qameta.allure</groupId>
                <artifactId>allure-maven</artifactId>
                <version>2.9</version>

                    <configuration>
                        <reportVersion>2.6.0</reportVersion>
                        <resultsPattern>${allure.results_pattern}</resultsPattern>
    <!--                     <outputDirectory>${allure.report.directory}</outputDirectory> -->
    <!--                     <allureResultsDirectory>${allure.results.directory}</allureResultsDirectory> -->
                        <resultsDirectory>${allure.results.directory}</resultsDirectory>
                        <reportDirectory>${allure.report.directory}</reportDirectory>
                    </configuration>
            </plugin>
        </plugins>
</reporting>

您可以通过创建具有以下内容的 src/test/resources/allure.properties 文件来更改 allure-results 生成路径:

allure.results.directory=target/allure-results

已更新 此外,在创建 allure.properties

之后从所有 allure-results 变量中清除 pom.xml 也是个好主意