1
有没有人知道我可以如何让mockDomain在JUnit测试中工作?为什么在Grails中保存不能与mockdomain一起工作?
以下测试失败:
void testRoleSave()
{
def roles = []
mockDomain(Role, roles)
Role role = new Role(authority: "baba");
role.save(flush: true, failOnError: true)
println role.errors
assertNotNull(role.id)
println role.id
assertEquals(Role.getAll().size(), 1)
//assertEquals(roles.size(), 1)
}
错误:
junit.framework.AssertionFailedError: junit.framework.AssertionFailedError: expected:<0> but was:<1>
at ....testRoleSave(ReceiveMailControllerTests.groovy:36)
'assertEquals'应该有相反的参数顺序:第一个预期,然后是实际。 –