Reputation: 1
I am trying to add retryAnalyzer and listener to my test framework to retry tests if it's failed.
In runtime of my suites I get the following error: "Listener interface org.testng.ITestListener must be one of ITestListener, ISuiteListener, IReporter, IAnnotationTransformer, IMethodInterceptor or IInvokedMethodListener". Since ITestListener is in the list of "one of...", I can't get where I was mistaken.
every testNG class has
@Test(retryAnalyzer=RetryAnalyzer.class)
@Listeners({test.base.RetryTestListener.class})
suites has
<listeners>
<listener class-name="test.base.RetryTestListener" />
</listeners>
In RetryTestListener I override onTestSuccess and onTestFailure methods:
public class RetryTestListener extends TestListenerAdapter {
private int count = 0;
private int maxCount = 3;
@Override
public void onTestFailure(ITestResult result) {
if(result.getMethod().getRetryAnalyzer().retry(result)) {
count++;
result.setStatus(ITestResult.SKIP);
}else{count = 0;}
Reporter.setCurrentTestResult(null);
}
@Override
public void onTestSuccess(ITestResult result)
{count = 0;}
declarations for TestListenerAdapter and implemented interfaces are:
public class TestListenerAdapter implements IResultListener2
IResultListener2:
public interface IResultListener2 extends IResultListener, IConfigurationListener2 {
IResultListener:
public interface IResultListener extends ITestListener, IConfigurationListener {
Maybe there is somebody who has ever faced such error message. Thanks in advance
Upvotes: 0
Views: 2004
Reputation: 8531
The error suggests that the listener that you have defined doesnt implement any of the Listener interfaces that testng exposes. It has to implement one of the said listeners to be added to listeners.
You can just specify your implementing class on your test, like you did in your @Test annotation.
Upvotes: 0