正在测试功能[
{
"hospitalNumber": null,
"patientName": null,
"totalAmount": 31104
},
{
"hospitalNumber": "",
"patientName": "LastName, FirstName",
"totalAmount": 3439.8
}
]
,其中预期的行为是如果removeStudent(Student s, Group g)
为空,则调用Group
不会有任何作用。
我们如何测试这种行为?
以下是一些方法:
removeStudent
仅能编写一个测试用例:
private final Map<Group, Set<Student>> studentsInGroup = new HashMap<>();
public void removeStudent(Student s, Group g) {
Collection<Student> students = getStudentsInGroup(g);
studentsInGroup.remove(s);
}
public Collection<Student> getStudentsInGroup(Group g) {
Collection<Student> students = studentsInGroup.get(g);
if (students == null) {
students = new HashSet<Student>();
}
return students;
}
这是测试要求的正确案例吗?我还可以添加什么测试?