In this post I will show you how to create custom testng listener class and override its methods.
Create java class like I created below “MyListner” and inherit “TestListenerAdapter” testing class.
Create java class like I created below “MyListner” and inherit “TestListenerAdapter” testing class.
package com.test;
import org.testng.ITestResult;
import org.testng.TestListenerAdapter;
public class MyListner extends
TestListenerAdapter {
@Override
public void onTestFailure(ITestResult result) {
System.out.println(result.getName()
+ " Test method failed\n");
}
@Override
public void onTestSkipped(ITestResult result) {
System.out.println(result.getName()
+ " Test method skipped\n");
}
@Override
public void onTestSuccess(ITestResult result) {
System.out.println(result.getName()
+ " Test method success\n");
}
}