阅读有关 Grails 单元测试的文档时,我发现了以下内容:
In Grails you need to be particularly aware of the difference between unit and integration tests because in unit test Grails does not inject any of the dynamic methods present during integration tests at runtime.
^ Grails 9.1 Unit Testing Documenation
有了这个,我假设缺少的注入(inject)方法是指:
getBy*
, .save()
来自 GORM 和 Hibernate 的方法 他们在这里谈论的还有其他动态注入(inject)的东西吗?
最佳答案
基本上所有与 GORM 相关的方法(动态查找器等)都是文档中指出的。它们在单元测试(没有模拟)中不可用,仅在集成测试中可用。
以下是单元测试期间不可用的大多数方法。
addTo
attach
count
countBy
createCriteria
delete
discard
executeQuery
executeUpdate
exists
find
findAll
findAllBy
findAllWhere
findBy
findWhere
get
getAll
getDirtyPropertyNames
getPersistentValues
ident
isAttached
isDirty
list
listOrderBy
load
lock
merge
read
refresh
removeFrom
save
关于hibernate - Grails 单元测试中不包含哪些动态方法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7699000/