在目标文件夹下未生成所有结果目录

时间:2017-07-14 21:43:47

标签: java maven allure

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

我已经浏览了倾城文档网站,他们建议在系统路径中添加<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>

2 个答案:

答案 0 :(得分:4)

在您的测试资源(通常为allure.properties)下创建一个文件src/test/resources,其中包含以下内容:

allure.results.directory=target/allure-results

答案 1 :(得分:0)

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

在systemPropertyVariables中创建以下条目:

<allure.results.directory>target/allure-results</allure.results.directory>