我需要知道如何解决这个问题
public class SigFX extends SigProduct {
private FX fx;
public SigFX(final ReportRo row) {
super(row);
fx = (FX) getTrade().getProduct();
}
@Override
public Object getStrtDt() {
return getTrade().getTradeDate();
}
@Override
public Object getEndDt() {
return getTrade().getSettleDate();
}
}
我需要为此类方法启动单元测试(JUnit 4),但我真的不知道如何解决在 testClass 中实例化 SigFX 的问题,因为它有一个对象类型 ReportRo 作为参数。
最佳答案
你可以这样做:
final ReportRo row = new ReportRo(); //I don't know class ReportRo, so it might be possible that you have to add some parameters to constructor.
final SigFX sigFX = new SigFX(row);
//you can access your methods of sigFX as usual and test it as you want
关于java - 如何对在具有未知对象参数的构造函数的类中工作的方法进行单元测试 (Junit 4),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58963517/