Allure With Maven And TestNG

By | 17th July 2018

In this blog we are going to enhance selenium reporting using Allure With Maven And TestNG.

Why to Use Allure Reporting:

Allure has made understanding of reports better with a lot of features. Allure gives a graphical representation of the results. Depending on the Severity level of the test scripts we can analyze the report faster. We can also get the execution time of the test scripts. Apart from these Allure also provide the facility to attach the screenshot without any extra effort.

We will be implementing Allure with Maven and TestNG in this blog.

Project Structure:

Project structure will be similar to this:


Maven Updates:
We first have to make our project capable to run Allure. For this we will be adding following dependencies into our pom.xml.

Test Listener:
We will be creating a class called TestListener, so that depending on the test case/method status, we can perform some actions and get the result in Allure.

TestListener class will be implementing ITestListener interface to get the capability to perform actions on various status on the test script.
Now next step is to override the methods from the ITestListener interface.
Here the onTestFailure method has been overridden to attach screenshot and save text logs on test failure.

Test Script:
First of all, we will be adding a Listener TestListener class.
Now we will be calling Allure annotations in the test script.
@Severity: This will add the severity level of the test case.
@Description: This will add the description of the test case.

For all the methods under Pages, we can have @Step annotation.
@Step: Will tell us whatever steps we have executed.

Driver Test Case:

Driver Helper:

Test Execution:
We have to run our test with maven.

Generating Report:
First of all we need to create a folder where the report can be saved. We can create it in our Project itself.

Get the HTML Allure Report:
To get the html report, we need to follow the steps:
1. Open terminal
2. cd to your project
3. Type allure serve allure-results
Generated allure report will get open in your default browser.

We can find these many format of the results.




Allure also differentiate the result status on the condition of the test failure.
Lets say your test has been failed because your locator was incorrect, so it will not mark as fail, rather it will say that test is broken
But lets say your test has been failed as your assertion failed, so it will mark your test as fail.

6 thoughts on “Allure With Maven And TestNG

  1. furtdso linopv

    What’s Going down i’m new to this, I stumbled upon this I’ve found It absolutely useful and it has aided me out loads. I am hoping to contribute & assist different customers like its aided me. Good job.

  2. Marcy

    Nice post. I was checking constantly this blog and I am impressed!
    Very useful info particularly the ultimate part :
    ) I take care of such information much. I was seeking this particular info for a very long time.
    Thank you and good luck.

  3. kraus

    Hi! I could have sworn I’ve been to this website before but after
    browsing through a few of the articles I realized it’s new
    to me. Nonetheless, I’m definitely happy I found it
    and I’ll be bookmarking it and checking back frequently!

  4. minecraft

    If you desire to improve your experience simply keep visiting
    this website and be updated with the newest technologies posted here.


Leave a Reply

Your email address will not be published. Required fields are marked *