Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Test Automation: Reporting With TestNG and Allure

DZone's Guide to

Test Automation: Reporting With TestNG and Allure

Have a look at how to generate various test reports with open-source tools Allure and TestNG.

· Performance Zone ·
Free Resource

Sensu is an open source monitoring event pipeline. Try it today.

TestNG is a testing framework that enables you to cover end-to-end, functional, integration, and other types of tests. Allure is an open-source framework designed to generate test reports in a convenient and clear form. Integrating TestNG and Allure, you'll optimize the reporting activities. Let's have a look how to do that.

Using the Gradle project, add the TestNG dependency and include the task for Allure report generation to build.gradle.

Add a simple assert, after which you’ll get a test with failed status:

 assertThat("aaaa").contains("bbbb"); 

After, you’ll get the following error message:

Expecting:

<"aaaa">

to contain:

<"bbbb">


Run  gradlew clean test and check the report in the folder /build/reports/tests:

Let’s have a look how checkings/errors are logged in Allure reports. Execute gradlew allureReport. The report is in the folder /build/reports/allure-report. Overview section represents one failed test:

Move to Categories. Opening all the sections, you can see that Product Defects represents a short error message about failed assert:

You can look through a full stack trace in the Suites section:

Instead of an assert, put:

 assertThat("aaaa").contains("aaa"); 

After executing the command gradlew clean test allureReport =, you’ll get the report that includes successfully passed test:

The message "There are no items" appears in the Categories section.

So, AssertJ can work properly with TestNG as well as log tests and errors in Allure reports.

Sensu: workflow automation for monitoring. Learn more—download the whitepaper.

Topics:
testng ,allure ,performance ,tutorial ,test automation

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}