【发布时间】:2015-01-10 22:12:15
【问题描述】:
我有一个属性我不想为空的类。
setter 中的 Si 如下所示:
public void setFoo(String bar)
{
if (bar == null)
throw new IllegalArgumentException("Should not be null");
foo = bar;
}
在我的 JUnit 测试用例中,我想断言,如果我执行 obj.setFoo(null),它将失败。 我该怎么做?
【问题讨论】:
-
你试过
Assert.assertNotNull()吗?
标签: java unit-testing junit