13

I upgraded to latest <allure2.version>2.0-BETA14 in my Maven project. test-results folder is getting generated under the project directory instead of target directory.

I have gone through the allure documentation website and they have suggest to add <allure.results.directory> in the system path to override but it doesn't seem to be working.

I am building my TestNG suite programatically. This was working absolutely fine with allure1.

Below is my 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>

user3290656
  • 339
  • 1
  • 3
  • 10

5 Answers5

16

Create a file allure.properties under your test resources (usually it is src/test/resources) with the following content:

allure.results.directory=target/allure-results
Dmitry Baev
  • 2,270
  • 1
  • 14
  • 24
  • 1
    It is generated in local but not in jenkins what could be the issue? – Ashok kumar Ganesan Jul 01 '21 at 14:12
  • 1
    @AshokkumarGanesan. were u able to find the issue. I am also able to generate results on Local but when pipeline is running no allure-results is generating – Karan Feb 14 '22 at 16:34
  • @Karan In my case, I deleted the job and created a new one with the *target/allure-results* path under post build actions and it started to work well – Ashok kumar Ganesan Feb 15 '22 at 03:21
  • Thanks @AshokkumarGanesan , it also worked for us by manually creating allure-results folder one level up of project repo. we took reference of this link https://stackoverflow.com/questions/53152923/allure-results-does-not-exists-in-jenkins – Karan Feb 15 '22 at 09:28
7

Try out this solution - https://github.com/allure-framework/allure-maven/issues/30#issuecomment-276441970

In systemPropertyVariables create the following entry:

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

Tomahawks
  • 71
  • 1
  • 1
1

If you have allure-results directory generated in your main project directory (instead being under ./target) as I did, then you want to run allure:report form commandline, then you might have luck with following command

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

Here i use mac/linux directory separator, so on windows you might need backward slash instead.

Lauri
  • 1,859
  • 2
  • 14
  • 17
0

Sometimes, there might also be a case that in your allure.properties, the path that you have written for allure.results.directory has a prefix "/". Remove that and try again.

Meaning,

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

should be changed to

allure.results.directory=target/allure-results

0

I moved allure.properties from "src.test.java" to "src.test" and now allure-results generating in /target/allure-results. So you may try to move allure.properties to another folder