Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我们得到了一个 jar 文件来对这些方法进行黑盒测试。我知道一个测试应该给我们一个运行时异常,但我得到一个空指针异常。我的问题是我的设置是否正确,你们知道我哪里出错了吗?
包资源管理器是这样的
单个测试用例
将 JAR 文件正确导入构建路径?
给出错误错误的测试用例
UML 图
我从未使用过 Eclipse,但从您的输出来看,一切都设置得很好。
我对NullPointerException两者都不感到惊讶;你打电话addCourse()并通过null而不是Course.
NullPointerException
addCourse()
null
Course
这显然是功课。我不知道你的方向是什么,但如果你不希望该方法抛出 NPE,你可能不应该在那里放置空值。
由于您要查找的异常是CourseOverlapException,因此您可能应该尝试添加两个SingleLectureCourse具有重叠时间范围的 s。
CourseOverlapException
SingleLectureCourse