<分区>
我有以下测试-
public void testStore() throws ItemNotStoredException {
Boolean result = itemSrvc.storeItem(items);
Assert.assertFalse(result);
}
但我收到错误类型不匹配:无法从 void 转换为 boolean 值。
它正在测试什么......
public void storeItem(Items items) throws ItemNotStoredException {
try {
ObjectOutputStream output = new
ObjectOutputStream (new FileOutputStream ("itemdatabase"));
output.writeObject(items);
output.flush();
output.close();
} catch (IOException e) {
throw new ItemNotStoredException ("Unable to store file", e);
}
}
澄清一下——我不想让 storeItem 返回任何东西,我只是想测试它,所以也许我的测试本身就是错误的。如果是这种情况,我们将不胜感激任何有关如何修复测试的建议。