Grails单元测试中不包含哪些动态方法? [英] Which Dynamic methods are not included in Grails Unit Tests?
问题描述
$ b
在Grails中,您需要特别注意
单元和集成测试,因为在单元测试中,Grails不会在
运行时的集成测试期间注入
的任何动态方法。
然后,我假设缺少的注入方法指的是:
- 来自GORM和Hibernate的
getBy *
,.save()
li>
是否还有其他动态注入的内容是他们在这里讨论的?
基本上所有与GORM有关的方法(动态查找器等)都是在doc中指出的umentation。它们不能在单元测试中使用(没有模拟),只能在集成测试中使用。
以下是在单元测试中不可用的大多数方法。
addTo
附加
计数
countBy
createCriteria
删除
丢弃
executeQuery
executeUpdate
存在
查找
findAll
findAllBy
findAllWhere
findBy
findWhere
get
getAll
getDirtyPropertyNames
getPersistentValues
ident
isAttached
isDirty
list
listOrderBy
load
锁定
合并
读取
刷新
removeFrom
保存
Reading the documentation on Grails Unit testing I came across the following:
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
And with this I'm assuming the missing injected methods refer to:
- the
getBy*
,.save()
methods from GORM and Hibernate
Is there anything else that is dynamically injected that they are talking about here?
Essentially all of the GORM related methods (dynamic finders, etc.) are what are being pointed out in the documentation. They are not available in unit tests (without mocking), only in integration tests.
The following are the majority of the methods not available during unit tests.
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
这篇关于Grails单元测试中不包含哪些动态方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!