Skip to content
Marcus Kaufmann edited this page Jan 15, 2018 · 21 revisions

[[Allure|https://github.com/allure-framework/allure2]] is a test report tool that creates a nifty HTML report out of test execution results. Allure brings also some Java programming features that allows you to determine steps, add parameters and attachments to enhance the created report. See more their documentation for more details Allure documentation

allure_report_example Check out their demo report

Reports are generated via Maven command mvn clean test allure:report which will clean the project, execute tests and finally generates the report from test results. Since Allure writes their own test results besides JUnit results the tool needs to be integrated into test cycle. Maven Surefire is a Maven plugin which covers test phase in lifecycle. You need to add the following configuration to your pom.xml in order to get Allure reports working.

<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>
    <aspectj.version>1.8.10</aspectj.version>
</properties>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.20.1</version>
            <configuration>
                <forkCount>4</forkCount><!-- parallel test execution -->
                <reuseForks>false</reuseForks>
                <argLine>-javaagent:"${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar"</argLine>
                <properties>
                    <property>
                        <name>listener</name>
                        <value>io.qameta.allure.junit4.AllureJunit4</value>
                    </property>
                </properties>
                <systemProperties>
                    <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>
                <dependency>
                    <groupId>org.apache.maven.surefire</groupId>
                    <artifactId>surefire-junit47</artifactId>
                    <version>2.20.1</version>
                </dependency>
            </dependencies>
        </plugin>
        <plugin>
            <groupId>io.qameta.allure</groupId>
            <artifactId>allure-maven</artifactId>
            <version>2.9</version>
            <configuration>
                <reportVersion>2.4.1</reportVersion>
            </configuration>
        </plugin>
    </plugins>
</build>

Defining steps There are different ways to define steps of your test case that are later on visible in the report. First you can define functions that are annotated. The @Step annotation on that method causes the

@Step("FirstStep")
public void myFirstStep()
{
	// do stuff
}
public void myTest()
{
	step("first step");
	// do stuff
	
	step("second step");
	// do stuff
}


@Step("\"{stepName}\" step")
public void step(String stepName)
{
}
Clone this wiki locally