1
我想測試域對象中等於的覆蓋,以確保'包含'的作品。單元測試機制無視我,儘管文檔和錯誤表示我應該能夠模擬addTo。Grails單元測試和模擬addTo
我的測試是:
@TestFor(Member)
@Mock([Member])
class MemberCategoryTests {
void testContains() {
MemberCategory schoolCat = new MemberCategory(name: "SCHOOL")
MemberCategory membersCat = new MemberCategory(name: "Members")
Member member = new Member(membershipNumber: "333333",
surname: "Tester",
forenames: "Jim",
preferredEmail: "[email protected]")
member.addToMemberCategories(schoolCat)
member.addToMemberCategories(membersCat)
MemberCategoryRedback memberCategoryRedback = new MemberCategoryRedback(name: "SCHOOL")
assert member.memberCategories.contains(memberCategoryRedback)
}
}
的錯誤是:
No signature of method: au.com.interlated.civiLink.Member.addToMemberCategories() is applicable for argument types: (au.com.interlated.civiLink.MemberCategory)
域對象是不是特別的。 MemberCategory實現了equals。
該文件說@Mock([YYY])應該做的伎倆:Naleid upgrading to grails 2 testing一樣unit testing addto
是 - 額外的@TestFor從問題中刪除錯誤。我無法確認需要保存,因爲包含()的測試報告不能以任何方式工作。謝謝 – Interlated