In the MyClass class that I'm testing, I have:
public void execute(){ service.call(ThisClass::method1); }
And further:
void method1(){do 1;} void method2(){do 2;}
And in the test:
@Mock Service service; @Test public void testCallMethod1() { MyClass myClass = new MyClass(); myClass.execute(); service.verify(any(Runnable.class)); }
And it works, but how can I verify that this parameter instead of any Runnable was method1, not method2?
I am looking for a solution that will look (for example, not working):
service.verify(eq(MyClass::method1.getRunnable()))
Anton source share