package cn.com.rzx.test;
public class A
{
private BInterfance bInterfance;
public A(BInterfance bInterfance)
{
this.bInterfance = bInterfance;
}
public String testMethod(String str)
{
return str + bInterfance.getString("b");
}
}
package cn.com.rzx.test;
public class B implements BInterfance
{
public String getString(String str){
return str+"77777777";
}
}
package cn.com.rzx.test;
public interface BInterfance
{
public String getString(String str);
}
package cn.com.rzx.test;
public class MockB implements BInterfance
{
private String str;
public String getString(String str){
return str;
}
public void setString(String str){
this.str = str;
}
}
package cn.com.rzx.test;
import junit.framework.TestCase;
public class ATest extends TestCase
{
protected BInterfance mock;
protected A a;
protected void setUp() throws Exception
{
super.setUp();
mock = new MockB();
a = new A(mock);
}
/*
* “cn.com.rzx.test.A.testMethod(String)”的测试方法
*/
public void testTestMethod()
{
assertEquals(a.testMethod("a"), "ab");
}
}