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 becaus开发者_JAVA技巧e 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
精彩评论