0
0
Selenium Javatesting~5 mins

TestNG default reports in Selenium Java

Choose your learning style9 modes available
Introduction

TestNG default reports help you see which tests passed or failed without extra setup. They give quick feedback on your test results.

After running automated tests to check if all tests passed.
When you want a simple summary of test results without custom reports.
To quickly find failed tests and their error messages.
When sharing test results with your team in a standard format.
To track test execution over time using the generated report files.
Syntax
Selenium Java
TestNG automatically generates reports after test execution.

Reports are saved in the 'test-output' folder by default.

You do not need to write code to create these reports.

The main report files are index.html and emailable-report.html.

Reports include test status, execution time, and error details for failures.

Examples
A simple test that will pass and appear in the default report.
Selenium Java
@Test
public void testExample() {
    Assert.assertTrue(true);
}
A test that fails and will be marked as failed in the default report.
Selenium Java
@Test
public void testFail() {
    Assert.assertTrue(false);
}
Sample Program

This test class has two tests: one passes and one fails. After running with TestNG, the default report will show one pass and one fail.

Selenium Java
import org.testng.Assert;
import org.testng.annotations.Test;

public class SampleTest {

    @Test
    public void testPass() {
        Assert.assertTrue(true);
    }

    @Test
    public void testFail() {
        Assert.assertTrue(false, "This test is designed to fail.");
    }
}
OutputSuccess
Important Notes

TestNG creates the test-output folder automatically after tests run.

You can open test-output/index.html in a browser to see a detailed report.

Reports update every time you run tests, showing the latest results.

Summary

TestNG default reports show test results automatically after running tests.

They help quickly identify passed and failed tests with error details.

No extra code is needed to generate these reports; just run your tests.