I am having a class:
class A
{
public void methodA()
{
new B().methodB("string");
----
----
}
}
class B
{
public void methodB(String s)
{
---
---
}
}
I need to write a mock, so that I can bypass call to methodB(), inside class A's methodA().
I tried doing:
//B b = PowerMockito.spy(new B());
//PowerMockito.doNothing().when(b).methodB(null);
Also tried spying:
//B b = Mockito.spy(new B());
//Mockito.doNothing().when(b).methodB("dummy");
But nothing working, and the methodB(), is getting invoked in my unit test.