Search
  • +44-7459919437 (UK- WhatsApp & Direct Call) | +91-6383544892 (India - WhatsApp Only) | Email Id : vinothrwins@gmail.com
Vinoth Tech Solutions
  • Home
  • Selenium Java Online Training
  • Self Paced Video Course
    • Selenium Course Curriculum
    • Cypress Course Curriculum
    • Playwright Course Curriculum
  • Tutorials
  • Demo Sites
    • E-Commerce Demo Application
    • Practice Automation
      • Demo Page Healthcare
      • Registration Form
      • Transaction Details
      • DropDown
      • Mouse Event
      • Keyboard Events
      • Alert and Popup
      • Multiple Windows
      • iFrames
      • Wait WebElement
      • WebTable
  • FAQS
  • About Me & Feedback
    • Placed Students Feedback
    • Online Training Feedback
    • LinkedIn Profile
    • TechTalk
  • Free YouTube Courses
    • Python for Automation
    • Free QA Video Courses
      • Manual Testing
      • Java For Automation
      • Selenium Webdriver
      • TestNG
      • Cucumber BDD
      • UFT(QTP) Automation
    • Free Data Science Courses
      • Artificial Intelligence for Beginners
      • Python For A.I
      • Python Pandas
      • Python NumPy
      • Mathematics for A.I
  • Home
  • Selenium Java Online Training
  • Self Paced Video Course
    • Selenium Course Curriculum
    • Cypress Course Curriculum
    • Playwright Course Curriculum
  • Tutorials
  • Demo Sites
    • E-Commerce Demo Application
    • Practice Automation
      • Demo Page Healthcare
      • Registration Form
      • Transaction Details
      • DropDown
      • Mouse Event
      • Keyboard Events
      • Alert and Popup
      • Multiple Windows
      • iFrames
      • Wait WebElement
      • WebTable
  • FAQS
  • About Me & Feedback
    • Placed Students Feedback
    • Online Training Feedback
    • LinkedIn Profile
    • TechTalk
  • Free YouTube Courses
    • Python for Automation
    • Free QA Video Courses
      • Manual Testing
      • Java For Automation
      • Selenium Webdriver
      • TestNG
      • Cucumber BDD
      • UFT(QTP) Automation
    • Free Data Science Courses
      • Artificial Intelligence for Beginners
      • Python For A.I
      • Python Pandas
      • Python NumPy
      • Mathematics for A.I

TestNG Framework

  • What is TestNG Framework?
  • Advantages and Disadvantages of TestNG:
  • Difference between TestNG And Junit framework
  • What is TestNG Annotations?
  • Install TestNG In Eclipse & IntelliJ?
  •  Hierarchy In TestNG Annotations
  • TestNG’s prioritization
  • TestNG Dependent
  • Reporter Class in TestNG
  • TestNG Reports
  • Assertions in TestNG
  • TestNG Groups
  • TestNG Parameters
  •  Cross-Browser Testing in TestNG
  •  Parallel Testing in TestNG
  • Data Providers
  • TestNG Listeners
  • Rerunning failed tests in TestNG
View Categories
  • Home
  • Tutorials
  • TestNG
  • 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


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:

@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
© 2018 – 2025 Vinoth Tech Solutions Ltd (UK), Reg. No: 16489105