Created
August 10, 2011 07:07
-
-
Save stratwine/1136284 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When is instance of B created here ?