运行时JUnit测试错误

时间:2014-04-10 12:30:50

标签: java junit

运行JUnit测试时出错

public class DamActionsTester 
{
    private DamActions damAction;
    private final Integer defualtRelease = 50;
    private final Integer damCapacity = 1053;
    private final Integer jobDuration = 14;
    private WaterLog log;

@Before
public void newDamAtctions() throws SimulationException
{
    damAction = new DamActions(damCapacity, defualtRelease, jobDuration, log);
}

在这里,JUnit测试说

java.lang.NullPointerException
    at asgn1Solution.DamActions.<init>(DamActions.java:37)
    at asgn1Solution.DamActionsTester.newDamAtctions(DamActionsTester.java:23)

有像这样的错误。这是我的部分错误

damLog.addEntry(damCapacity/2);

为此,如何修复它来运行它?

1 个答案:

答案 0 :(得分:0)

传递给构造函数时,接缝log为null:

private WaterLog log;

它永远不会被初始化,对吧?