maven 未在目标文件夹下生成吸引结果目录

91zkwejq  于 2022-12-11  发布在  Maven
关注(0)|答案(4)|浏览(151)

我在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>
b1zrtrql

b1zrtrql1#

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

allure.results.directory=target/allure-results
0s7z1bwu

0s7z1bwu2#

试用此解决方案-https://github.com/allure-framework/allure-maven/issues/30#issuecomment-276441970
在systemPropertyVariables中创建以下条目:
<allure.results.directory>target/allure-results</allure.results.directory>

nzk0hqpo

nzk0hqpo3#

如果您像我一样在主项目目录中生成了***allure-results***目录(而不是在***./target***下),那么您希望运行***allure:report***form命令行,那么您可能会遇到以下命令

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

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

cbjzeqam

cbjzeqam4#

有时候,在您的www.example.com中allure.properties,您为allure.results.directory编写的路径可能会有前缀“/"。请删除该前缀,然后重试。
意、
allure.results.directory=/target/allure-results
应改为
allure.results.directory=target/allure-results

相关问题