Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/eclipse/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
为什么在Grails中save不能与mockdomain一起工作?_Grails_Gorm - Fatal编程技术网

为什么在Grails中save不能与mockdomain一起工作?

为什么在Grails中save不能与mockdomain一起工作?,grails,gorm,Grails,Gorm,有人知道如何让mockDomain在JUnit测试中工作吗 以下测试失败: 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)

有人知道如何让mockDomain在JUnit测试中工作吗

以下测试失败:

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)
junit.framework.AssertionFailedError:junit.framework.AssertionFailedError:expected:但是:
at…testRoleSave(ReceiveMailControllerTests.groovy:36)

使用Role.list()或Role.count()代替Role.getAll()。

使用Role.list()或Role.count()代替Role.getAll()。

assertEquals应具有相反的参数顺序:首先预期,然后实际。
assertEquals应具有相反的参数顺序:首先预期,然后实际。