Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to integrate Allure Report in karate API automation project

We are using Karate heavily for various projects and though the report generated using karate Reports are more than anyone would need. I am still interested in getting Allure integrated in the mix.

Added allure-junit4 dependency and added allure listener

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.20</version>
                <configuration>
                    <argLine>
                        -javaagent:"${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar"
                         <!-- -Dcucumber.options="&#45;&#45;plugin io.qameta.allure.cucumberjvm.AllureCucumberJvm"-->
                    </argLine>
                    <properties>
                        <property>
                            <name>listener</name>
                            <value>io.qameta.allure.junit4.AllureJunit4</value>
                        </property>
                    </properties>

                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>org.aspectj</groupId>
                        <artifactId>aspectjweaver</artifactId>
                        <version>${aspectj.version}</version>
                    </dependency>
                </dependencies>
            </plugin>


Now allure-results is getting created and I can see report but it's almost blank.

Generated Allure Report

How can I get allure report generated on karate based project?

like image 766
Amit Vyas Avatar asked Oct 27 '25 18:10

Amit Vyas


2 Answers

If Allure supports the Cucumber JSON output it should work. Else suggest you take this up with the Allure team.

You can refer to this thread (for Extent): https://github.com/intuit/karate/issues/619

EDIT: Since I refer anyone asking about extending / custom reports to this answer, read on.

In Karate 1.0 onwards, the Results object can be used to get all data about the test results. Also multiple JSON files will be output to the <build>/karate-reports. You can even re-try some tests and merge the results: https://github.com/intuit/karate/wiki/1.0-upgrade-guide#retry-framework-experimental

Also please be aware of changes to the Java hooks, it is called RuntimeHook now: https://github.com/intuit/karate/wiki/1.0-upgrade-guide#hooks

For those using XRay - there is official documentation: https://docs.getxray.app/display/XRAYCLOUD/Testing+APIs+using+Karate+DSL

Regarding Report Portal - there is a need for the official adapter to be upgraded: https://stackoverflow.com/a/60156120/143475 - but that thread has a few links to examples of people who have done it.

like image 108
Peter Thomas Avatar answered Oct 30 '25 13:10

Peter Thomas


Allure now provides official Karate integration.

First, you need to add the dependency

<dependency>
    <groupId>io.qameta.allure</groupId>
    <artifactId>allure-karate</artifactId>
    <version>2.29.0</version>
</dependency>

Then, you need to register a hook to the runner:

com.intuit.karate.Runner.builder()
.hook(new AllureKarate())

The working example can be found here: https://github.com/allure-examples/allure-karate-example

like image 30
Dmitry Baev Avatar answered Oct 30 '25 13:10

Dmitry Baev