【问题标题】:allure-results directory not generated under target folder目标文件夹下未生成 allure-results 目录
【发布时间】:2017-07-14 21:43:47
【问题描述】:

我在我的 Maven 项目中升级到了最新的 <allure2.version>2.0-BETA14test-results 文件夹在项目目录而不是target 目录下生成。

我浏览了 allure 文档网站,他们建议在系统路径中添加 <allure.results.directory> 以覆盖,但它似乎不起作用。

我正在以编程方式构建我的 TestNG 套件。这在 allure1 上运行得非常好。

下面是我的pom.xml

<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.mycompany.test.projectA</groupId>
<artifactId>scarpbook</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>

<name>scarpbook</name>
<url>http://maven.apache.org</url>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
    <java.version>1.8</java.version>

    <testng.version>6.10</testng.version>

    <surefire.plugin.version>2.19.1</surefire.plugin.version>
    <allure.version>2.0-BETA14</allure.version>
    <aspectj.version>1.8.10</aspectj.version>
    <allure.results.directory>target/allure-results</allure.results.directory>
    <allure.report.directory>target/allure-report</allure.report.directory>
    <tms>
        https://github.com/allure-framework/allure-docs/issues/{}
    </tms>

</properties>

<dependencies>

    <dependency>
        <groupId>com.mycompany.testlib</groupId>
        <artifactId>lib</artifactId>
        <version>1.0</version>
    </dependency>

    <dependency>
        <groupId>org.testng</groupId>
        <artifactId>testng</artifactId>
        <version>${testng.version}</version>
    </dependency>
    <dependency>
        <groupId>io.qameta.allure</groupId>
        <artifactId>allure-testng</artifactId>
        <version>${allure.version}</version>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-simple</artifactId>
        <version>1.7.21</version>
        <scope>test</scope>
    </dependency>

</dependencies>

<build>

    <plugins>

        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>exec-maven-plugin</artifactId>
            <version>1.1.1</version>
            <executions>
                <execution>
                    <goals>
                        <goal>exec</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <executable>java</executable>
                <mainClass>com.mycompany.testlib.testrunner</mainClass>
            </configuration>
        </plugin>

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.18.1</version>
            <configuration>
                <testFailureIgnore>true</testFailureIgnore>
                <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>
            </configuration>
            <dependencies>
                <dependency>
                    <groupId>org.aspectj</groupId>
                    <artifactId>aspectjweaver</artifactId>
                    <version>${aspectj.version}</version>
                </dependency>
            </dependencies>
        </plugin>
    </plugins>
</build>
<reporting>
    <excludeDefaults>true</excludeDefaults>
    <plugins>
        <plugin>
            <groupId>io.qameta.allure</groupId>
            <artifactId>allure-maven</artifactId>
            <version>2.8</version>
                <configuration>
                    <outputDirectory>${basedir}/target/allure-reports/</outputDirectory>
                    <allureResultsDirectory>${basedir}/target/allure-results</allureResultsDirectory>
                </configuration>
        </plugin>
    </plugins>
</reporting>

【问题讨论】:

  • 你是如何运行测试的?
  • mvn clean install exec:java 站点

标签: java maven allure


【解决方案1】:

在你的测试资源下创建一个文件allure.properties(通常是src/test/resources),内容如下:

allure.results.directory=target/allure-results

【讨论】:

  • 它是在本地生成的,但不是在 jenkins 中生成的,可能是什么问题?
  • @AshokkumarGanesan。你能找到问题吗?我也可以在 Local 上生成结果,但是当管道运行时,没有生成诱惑结果
  • @Karan 在我的情况下,我删除了该作业并在构建后操作下使用 target/allure-results 路径创建了一个新作业,它开始运行良好跨度>
  • 感谢@AshokkumarGanesan,它还可以通过手动创建项目 repo 上一级的 allure-results 文件夹来为我们工作。我们参考了这个链接stackoverflow.com/questions/53152923/…
【解决方案2】:

试试这个解决方案 - https://github.com/allure-framework/allure-maven/issues/30#issuecomment-276441970

在 systemPropertyVariables 中创建以下条目:

&lt;allure.results.directory&gt;target/allure-results&lt;/allure.results.directory&gt;

【讨论】:

    【解决方案3】:

    如果您在主项目目录中生成了 allure-results 目录(而不是在 ./target) 像我一样,那么你想运行 allure:report 形式的命令行,那么你可能会幸运地使用以下命令

    mvn allure:report -Dallure.results.directory=../allure-results
    

    这里我使用 mac/linux 目录分隔符,所以在 windows 上你可能需要反斜杠来代替。

    【讨论】:

      猜你喜欢
      • 2022-10-23
      • 1970-01-01
      • 2020-11-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-01-17
      • 2022-11-01
      相关资源
      最近更新 更多