问题描述
|
是否有可能为Java程序定义一些测试数据,从而使其易于人类阅读并可以通过编程方式解析为相关的函数调用和数据元素。
如果不可能,请使用Java实现此目的,因此我愿意使用Scala。被测试的代码是Java代码,并且不会移植到Scala。
interface someInterface {
class X {
// the member variables will always either
// be enums or intrinsic types
private int a;
public int a() { return this.a; };
public void a(int a) {this.a = a; };
private double b;
public double b() { return this.b; };
public void b(double b) {this.b = b; };
private String c;
public String c() { return this.c; };
public void c(String c) {this.c = c; };
}
enum A {
A_1,A_2
}
class Y {
// assume setters and getters as per X above
private A a;
private double b;
private String c;
private Z[] z;
}
class Z {
private int a;
private double b;
private String c;
}
Y function1(X x,String s);
}
public void boo() {
String[] testData = {
/* how can I specify this array so that
coo(...) can be called as below
would I be better off defining this
test code in Scala?
the classes and interfaces above:
someInterface,A,X,Y and Z are in Java
and will not be ported to Scala */
};
coo(testData);
}
public void coo(String[] testData) {
/* this function will know how to:
a) parse testData
b) use reflection to call
someInterface.functionXXX with parameters
as specified in testData
c) construct the return result as specified
in testData and compare against actual
return result */
}
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)