Skip to content

This is the demo project to analyze TestNG test results using MaxSoft TestNG Test Results Analyzer.

Notifications You must be signed in to change notification settings

osandadeshan/maxsoft-testng-test-results-analyzer-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MaxSoft TestNG Test Results Analyzer

Introduction

The main reason for developing this plugin is to provide an easy way to analyze the failed and skipped tests in test automation.

MaxSoft TestNG Test Results Analyzer comes with a built-in failed and skipped tests grouping mechanism. It will generate an Excel file with the failed and skipped tests against the reason. On the same Excel file, the second and third tabs contain the failure and skipped tests grouped under the reason. So it would be easy to identify the tests which failed or skipped due to the same reason.

Further, this library has built-in Extent reporter as well. So, no need to worry about the HTML report generation for test executions.

1. Test Analysis Report Features

Test Summary image

Failure Analysis - Table View image

Failure Analysis - Bar Chart image

Failure Analysis - Pie Chart image

Skipped Analysis - Table View image

Skipped Analysis - Bar Chart image

Skipped Analysis - Pie Chart image

2. Extent Report Features

Dashboard image

Tests - List View image

Tests - Single View image

Categories image

Exceptions image

Advantages

  • Automatically generates the Test Analysis Report after the test execution.
  • Automatically generates the Extent Report with screenshots after the test execution.
  • Reporter details can be configured through a property file.
  • No need to implement classes for Extent reporter or Test Analysis reporter.
  • Simple and easy to use.

Technologies/Frameworks Used

  • Java
  • TestNG
  • Apache POI
  • Extent Report
  • Selenium
  • Apache Maven

Supported Platforms

  • Windows
  • Linux
  • Mac OS

Supported Language

  • Java

Supported Test Runner

  • TestNG

How to use

Pre-Requisites:

  1. Java
  2. Maven

Steps:

  1. Add "MaxSoft TestNG Test Results Analyzer" dependency into "pom.xml".
    <repositories>
        <repository>
            <id>jitpack.io</id>
            <url>https://jitpack.io</url>
        </repository>
    </repositories>
	
    <dependencies>
        <dependency>
            <groupId>com.github.osandadeshan</groupId>
            <artifactId>maxsoft-testng-test-results-analyzer</artifactId>
            <version>1.2.0</version>
        </dependency>
    </dependencies>
  1. Create "test-results-analyzer.properties" in "src/main/resources".
# Test Analyzer Report Configs
extent_full_report_dir=./reports/html-reports
extent_screenshots_dir=./reports/html-reports/screenshots
test_analysis_reports_dir=./reports/test-analysis-reports
extent_report_file_name_prefix=test_execution_results_
test_analysis_report_file_name_prefix=test_analysis_report_

# Extent Report Configs
extent_reporter_theme=dark
extent_document_title=Test Execution Report
extent_reporter_name=Test Execution Report
application_name=AutomationPractice.com
environment=Production
browser=Chrome
operating_system=Windows 10 - 64 Bit
test_developer=Osanda Nimalarathna
  1. In the test automation code, find the place you are launching the WebDriver.

  2. Pass your WebDriver object to the "setDriver()" method which can be imported from "import static com.maxsoft.testngtestresultsanalyzer.DriverHolder.setDriver".

WebDriver driver = new ChromeDriver();
setDriver(driver);
  1. Update the places where your are using WebDriver object, into "getDriver()" method which can be imported from "import static com.maxsoft.testngtestresultsanalyzer.DriverHolder.getDriver".
getDriver().manage().window().maximize();
  1. An example test class.
package tests;

import io.github.bonigarcia.wdm.WebDriverManager;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import com.maxsoft.testngtestresultsanalyzer.annotations.Category;

import static com.maxsoft.testngtestresultsanalyzer.DriverHolder.getDriver;
import static com.maxsoft.testngtestresultsanalyzer.DriverHolder.setDriver;
import static com.maxsoft.testngtestresultsanalyzer.PropertyFileReader.getProperty;
import static org.testng.Assert.assertEquals;

/**
 * Project Name    : maxsoft-testng-test-results-analyzer
 * Developer       : Osanda Deshan
 * Version         : 1.0.0
 * Date            : 07/10/2021
 * Time            : 1:08 PM
 * Description     : This is a test class to test the login functionality
 **/

public class LoginTest {

    private WebElement emailTextBox;
    private WebElement passwordTextBox;
    private WebElement signInButton;

    @BeforeMethod
    public void before() {
        WebDriverManager.chromedriver().setup();
        WebDriver driver = new ChromeDriver();
        setDriver(driver);
        getDriver().manage().window().maximize();
        getDriver().get(getProperty("application_url"));
        emailTextBox = getDriver().findElement(By.id("email"));
        passwordTextBox = getDriver().findElement(By.id("passwd"));
        signInButton = getDriver().findElement(By.id("SubmitLogin"));
    }

    @Category("Login")
    @Test(description = "Verify that a valid user can login to the application")
    public void testValidLogin() {
        emailTextBox.sendKeys("osanda@mailinator.com");
        passwordTextBox.sendKeys("1qaz2wsx@");
        signInButton.click();
        assertEquals(getDriver().findElement(By.xpath("//div[@class='header_user_info']//span")).getText(), "Osanda Nimalarathna");
    }

    @Category("Login")
    @Test(description = "Verify that an invalid user cannot login to the application")
    public void testInvalidLogin() {
        emailTextBox.sendKeys("osanda@mailinator.com");
        passwordTextBox.sendKeys("1qaz2wsx@");
        signInButton.click();
        assertEquals(getDriver().getTitle(), "Login - My Store");
    }

    @AfterMethod
    public void after() {
        getDriver().quit();
    }
}
  1. Create the "testng.xml" by adding the "com.maxsoft.testngtestresultsanalyzer.TestAnalyzeReportListener" listener class.
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="Regression Test Suite">
    <listeners>
        <listener class-name="com.maxsoft.testngtestresultsanalyzer.TestAnalyzeReportListener"/>
    </listeners>
    <test name="Regression Test">
        <classes>
            <class name="tests.LoginTest"/>
        </classes>
    </test>
</suite>
  1. Run the "testng.xml".

License

MIT License MaxSoft TestNG Test Results Analyzer is released under MIT License

Copyright

Copyright 2021 MaxSoft.