Search
  • +44-7459919437 (UK- WhatsApp & Direct Call) | +91-6383544892 (India - WhatsApp Only) | Email Id : vinothtechsolutions@gmail.com
Vinoth Tech Solutions
  • Home
  • Tutorials
  • Free Complete QA Video Courses
    • Cypress Automation
    • Cucumber BDD Framework
    • JavaScript for Playwright & Cypress Automation
    • API Manual and Automation Testing using SoapUI
    • Appium 2.0 Mobile Automation
    • DevOps CI CD using Real Time Project Setup
  • Self Paced Video Course
    • Selenium Course Curriculum
    • Playwright Course Curriculum
  • About Me
    • LinkedIn Profile
    • Placed Students Feedback
    • Online Training Feedback
    • Tech Events & Sessions
  • FAQS
  • Demo Sites
    • Practice Automation
      • Registration Form
      • Transaction Details
      • DropDown
      • Basic Authentication
      • Mouse Event
      • Keyboard Events
      • Alert and Popup
      • Multiple Windows
      • iFrames
      • Wait WebElement
      • WebTable
      • Date Picker Calendar
    • E-Commerce Demo Application
    • Healthcare Demo Page
    • Create Account Demo Page
    • XPath Demo Page
    • Python JS Online Compiler
    • Python Tutorials
  • Home
  • Tutorials
  • Free Complete QA Video Courses
    • Cypress Automation
    • Cucumber BDD Framework
    • JavaScript for Playwright & Cypress Automation
    • API Manual and Automation Testing using SoapUI
    • Appium 2.0 Mobile Automation
    • DevOps CI CD using Real Time Project Setup
  • Self Paced Video Course
    • Selenium Course Curriculum
    • Playwright Course Curriculum
  • About Me
    • LinkedIn Profile
    • Placed Students Feedback
    • Online Training Feedback
    • Tech Events & Sessions
  • FAQS
  • Demo Sites
    • Practice Automation
      • Registration Form
      • Transaction Details
      • DropDown
      • Basic Authentication
      • Mouse Event
      • Keyboard Events
      • Alert and Popup
      • Multiple Windows
      • iFrames
      • Wait WebElement
      • WebTable
      • Date Picker Calendar
    • E-Commerce Demo Application
    • Healthcare Demo Page
    • Create Account Demo Page
    • XPath Demo Page
    • Python JS Online Compiler
    • Python Tutorials
View Categories
  • Home
  • Tutorials
  • TestNG Framework
  • Reporter Class in TestNG

Reporter Class in TestNG

Reporter Class in TestNG

1. What Is the Reporter Class in TestNG?

The org.testng.Reporter class provides static methods to log custom messages during test execution. These messages are collected by TestNG and surfaced in both the HTML reports (including the emailable report) and, optionally, in the console.

2. Syntax for Using Reporter

📄
filename.js
import org.testng.Reporter;

public class MyTest {

  @Test
  public void exampleTest() {

    Reporter.log("This is a custom log message");

    // … test steps …

    Reporter.log("Another message with newline<br/>", true);

  }

}

Reporter.log(String message)
Adds message to the report only.

Reporter.log(String message, boolean toConsole)
If toConsole == true, also prints message to System.out.

3. Logging Messages in Reports

Use Reporter.log(…) anywhere in your test or configuration methods:

📄
filename.js
@Test
public void loginTest() {

  Reporter.log("→ Navigating to login page", true);

  loginPage.open();

  Reporter.log("→ Entering credentials", false);

  loginPage.enterUsername("alice");

  loginPage.enterPassword("secret");

  loginPage.submit();

  Reporter.log("→ Submitted login form", true);

  Assert.assertTrue(dashboardPage.isVisible());

}

Messages accumulate under the “Reporter output” column/cell for each test in the HTML reports.

4. Viewing Logged Messages in the Emailable Report

Run your tests with TestNG.

Open test-output/emailable-report.html in your project.

In the table listing your test methods, expand the “Reporter output” section for each test to see all Reporter.log entries.

5. Viewing Reporter Logs in the Console

By default, Reporter.log(msg) does not print to console.

To echo a message to the console, pass true as the second argument:

Reporter.log(“This appears in both report and console”, true);

You’ll then see these lines interleaved with your test’s System.out output in Eclipse/IntelliJ’s console or your CI logs.

With the Reporter API you can insert rich, step-by-step logging into your TestNG reports—making it easy to trace what happened inside each test when you review the results.

Testng Framework
What are your Feelings

Share This Article :

  • Facebook
  • X
  • LinkedIn
TestNG DependentTestNG Reports
© 2025 V-Tech Solutions Ltd (UK), Reg. No: 16489105