public class abc{
public getTable(String table){
//some complex logic here.//to be skipped while testing
return "schemaName." + table;
}
public buildQueryMethod1(){
String sql = "select fields from "+getTable("table1") +
"union" +
"select fields from " + getTable("table2") +
.
.
.
return sql;
}
}
我想测试 buildQueryMethod1()。如何模拟 getTable 方法以使其返回“ABC”。字符串到传递给它的参数,并返回结果字符串任意次数,与传递的参数和方法被调用的次数无关。