Search code examples
mavencucumberallure

Allure generates an empty report Cucumber 7


I've read almost all questions here and still did not find the answer.

I have the following pom:

....
<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <selenium.version>4.7.2</selenium.version>
    <selenide>6.11.0</selenide>
    <allure>2.20.0</allure>
    <lombok>1.18.24</lombok>
    <slf4j.version>2.0.0-alpha6</slf4j.version>
    <rest.assured>5.1.1</rest.assured>
    <cucumber>7.11.1</cucumber>
    <allure>2.20.1</allure>
    <aspectj.version>1.9.9</aspectj.version>

</properties>

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>cucumber-bom</artifactId>
            <version>7.11.1</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
        <dependency>
            <groupId>org.junit</groupId>
            <artifactId>junit-bom</artifactId>
            <version>5.9.2</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

<dependencies>
    <dependency>
        <groupId>io.cucumber</groupId>
        <artifactId>cucumber-java</artifactId>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>io.cucumber</groupId>
        <artifactId>cucumber-junit-platform-engine</artifactId>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>io.cucumber</groupId>
        <artifactId>cucumber-junit</artifactId>
        <version>${cucumber}</version>
        <scope>test</scope>
    </dependency>

   ...

    <dependency>
        <groupId>io.qameta.allure</groupId>
        <artifactId>allure-cucumber7-jvm</artifactId>
        <version>${allure}</version>
    </dependency>
</dependencies>


<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.10.1</version>
            <configuration>
                <encoding>UTF-8</encoding>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>3.0.0-M8</version>
            <configuration>
                <argLine> -javaagent:"${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar"
                    -Dcucumber.options="--plugin io.qameta.allure.cucumber7jvm.AllureCucumber7Jvm"
                </argLine>
            </configuration>
            <dependencies>
                <dependency>
                    <groupId>org.aspectj</groupId>
                    <artifactId>aspectjweaver</artifactId>
                    <version>${aspectj.version}</version>
                </dependency>
            </dependencies>
        </plugin>
        <plugin>
            <groupId>io.qameta.allure</groupId>
            <artifactId>allure-maven</artifactId>
            <version>2.12.0</version>
            <configuration>
                <reportVersion>${allure}</reportVersion>
                <resultsDirectory>${project.build.directory}/allure-results</resultsDirectory>
            </configuration>
        </plugin>
    </plugins>
</build>

I run mvn clean test, get a results. I also use Cucumber Reports feature, this feature grabs the results correcty, but not Allure. Then call either allure serve or mvn allure: serve, but getting an empty report:Report

I really got stuck what I am doing wrong.


Solution

  • You are using cucumber.options="--plugin ... to enable the Allure plugin.

    This property was poorly designed replaced by individual properties in v5. For example cucumber.plugin=com.example.MyPlugin.

    Unfortunately there are many old tutorials around. But you should have seen a warning about this in the console. I added it 2 months ago.

    If you don't see this warning at all there is a good chance you are not passing the property to the JVM that runs the tests. You may want to read the documentation for argLine and Surefire in general.

    You can also put this property in either junit-platform.properties or cucumber.propeties depending which version of JUnit you use to run Cucumber.