Skip to content

Instantly share code, notes, and snippets.

@stratwine
Created August 10, 2011 07:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stratwine/1136284 to your computer and use it in GitHub Desktop.
Save stratwine/1136284 to your computer and use it in GitHub Desktop.
class A
{
B b;
public B getB()
{
return b;
}
public setB(B b)
{
this.b=b;
}
public String method(parameter) //method of class A
{
String str = b.method2();
return str;
}
}
class YourTest
{
public void testMethodShouldReturnExpectedString()
{
A a = new A();
B b = mock(B.class);
a.setB(b);
a.method(parameter);
}
}
@p-malhotra
Copy link

When is instance of B created here ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment