【发布时间】:2016-02-19 02:42:56
【问题描述】:
我的 Junit 测试一直失败并说junit.framework.AssertionFailedError: must be known item number 我尝试了多种不同的测试方法,但找不到解决方案。似乎找不到我正在输入的项目编号,但正如您从主类中看到的那样,项目编号“1”以及所有其他详细信息都在那里并且匹配!
我正在测试的课程:
package Purchase;
import java.util.*;
public class ItemStore implements saveItem {
private class saveDescriptor {
int itemNumber;
assert !isKnownItemNumber(itemNumber) : "must not be used item number";
assert unitPrice > 0 : "price must be positive";
assert sort == 0 || sort == 1 : "sort must be 0 or 1";
assert !description.trim().equals("") : "description must not be
【问题讨论】:
-
@ChiefTwoPencils 其他一切运行完美,只是我的测试由于某种原因无法通过。我是 Junit 新手,所以我不确定我做的测试是否不正确。
-
放入一些调试打印语句或使用调试器运行代码,并找出它在哪里下降。另见ericlippert.com/2014/03/05/how-to-debug-small-programs
标签: java arrays list methods junit