我只是想知道为什么一种测试delete()的方法能按预期工作,而另一种却没有呢?
在以下测试案例中:
def cFound = new Client( ... ).save()
def cFoundId = cFound.id
cFound.delete()
assertEquals 0, Client.count()
... assertEquals 0,Client.count()通过,但是...
assertFalse Client.exists( cFound.id )
assertNull Client.get(cFoundId)
...都失败了。可能是什么原因?
提前致谢。
最佳答案
尝试刷新上下文,以清除缓存:
cFound.delete(flush: true)
关于unit-testing - grails-测试delete(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7557975/