Which Dynamic methods are not included in Grails Unit Tests?

妖精的绣舞 提交于 2019-12-25 06:50:04

问题


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?


回答1:


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



来源:https://stackoverflow.com/questions/7699000/which-dynamic-methods-are-not-included-in-grails-unit-tests

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!