Search code examples
jenkinsjunit5java-11allure

Allure data/test-cases empty after spring-boot update (which updated junit4 to Junit 5). Shows NaN in jenkins


I updated my project's spring boot versions to 2.6.6 from 2.1.3.RELEASE.

This also updated Junit from Junit4 to Junit 5.

Everything works fine. All the test structures/imports are now modified to be Junit5 specific.

The only problem is, in Jenkins, I do not see any allure reports anymore. Everything shows up either NaN% or UNKNOWN.

I also modified the pom to be the same as mentioned here(https://docs.qameta.io/allure/) in the allure documentation for junit5. But still, it does not work.

On further inspection, I saw that the data/test-cases directory is empty now. Actually there is no such directory called test-cases under data anymore.

This is my pom below after updating spring-boot version.

<?xml version="1.0" encoding="UTF-8"?>
<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>
<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.6.6</version>
    <relativePath/>
</parent>

<artifactId>user-service</artifactId>
<packaging>jar</packaging>

<properties>
    <aspectj.version>1.9.2</aspectj.version>
</properties>

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-webflux</artifactId>
        <exclusions>
            <exclusion>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-logging</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
        <exclusions>
            <exclusion>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-logging</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>io.qameta.allure</groupId>
        <artifactId>allure-junit5</artifactId>
        <version>2.17.3</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.awaitility</groupId>
        <artifactId>awaitility</artifactId>
        <version>4.2.0</version>
        <scope>test</scope>
    </dependency>
</dependencies>
<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.22.0</version>
            <configuration>
                <properties>
                    <property>
                        <name>listener</name>
                        <value>io.qameta.allure.junit5.AllureJunit5</value>
                    </property>
                </properties>
                <testFailureIgnore>false</testFailureIgnore>
                <argLine>
                    -javaagent:"${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar"
                </argLine>
                <systemProperties>
                    <property>
                        <name>junit.jupiter.extensions.autodetection.enabled</name>
                        <value>true</value>
                    </property>
                    <property>
                        <name>allure.results.directory</name>
                        <value>${project.build.directory}/allure-results</value>
                    </property>
                </systemProperties>
            </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.11.2</version>
            <configuration>
                <reportVersion>2.14.0</reportVersion>
            </configuration>
        </plugin>
    </plugins>
</build>

The previous pom was the same as what is mentioned in the documentation. The change is only in the maven-surefire-plugin and the new dependency for allure-junit5.

My current Jenkins allure plugin version is 2.30.2.

What could be the issue? Is there any better documentation somewhere that I can refer to?


Solution

  • Worked after I changed the Allure Commandline to use the latest version. It was not working with 2.6.0. After updating to 2.20.0, it worked!