package com.factorymethod.demo;
public interface BaseObjects {
voidfunc();
}
// OuterObjects.java
package com.factorymethod.demo;
public class OuterObjects implements BaseObjects {
public void func() {
System.out.println("OuterObjects.func");
}
}
// LogicToBeTested.java, code to be tested
package com.factorymethod.demo;
public class LogicToBeTested {
public void doSomething() {
BaseObjects b = createBase();
b.func();
}
public BaseObjects createBase() {
return newOuterObjects();
}
}
延伸阅读
文章来源于领测软件测试网 https://www.ltesting.net/