Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Not getting "Add unimplemented methods" error in eclipse

I am working on Selenium with Java and using Listeners.

I created the class, imported the TestNG, and then added method as;

Public class Listener implements ITestListener{
}

I got an error at "ITestListner" and then imported "ITestListner(org.testng). After this it was expected that I will get an error for "Listener" but I didn't get any error.

I tried creating with abstract class but still didn't get the error.

package com.testng;

import org.testng.ITestListener;

public class Listeners implements ITestListener{

}

The expectation is when I move the cursor over "Listeners" I should get "Add unimplemented methods" option.

like image 690
Sagar Avatar asked Mar 08 '26 15:03

Sagar


2 Answers

Right click(on the Listeners class ) -> go to source-> click on overide/implement methods -> select the check boxes for the ITest listener (make sure all check box inside it should be checked )->click on oK. That's it !!!

like image 154
user12454227 Avatar answered Mar 10 '26 03:03

user12454227


As i got to know from the below link - TestNG 7.0.0 uses JDK8 and with it default methods within interfaces. What this means is that every listener would now have a default implementation (which doesn't do anything ) for all methods defined within the interface.

So now you won't see those indications from the IDE. The biggest benefit of default methods in interfaces is that let's say you are implementing an interface that has 10 methods defined in it, you can just implement whatever you need and the rest of the behavior comes via the default methods in the interface. Reference- https://github.com/cbeust/testng/issues/1964

like image 37
Rahul Kumrawat Avatar answered Mar 10 '26 05:03

Rahul Kumrawat