Grails - 如何单元测试addTo * [英] Grails - How to Unit Test addTo*

查看:145
本文介绍了Grails - 如何单元测试addTo *的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



感谢您的帮助。

解决方案

文档在第9.1节中说过:


在Grails中,您需要特殊性
知道单元
和集成测试,因为在
单元测试中,Grails 不会注入任何

集成测试和运行时出现的动态方法。


您必须在单元测试
中使用 mockDomain(DomainClassName)或写入一个集成测试:

DomainClassGrailsPlugin 被设置(<$ c $)时,Grails用一些Dynamic方法装饰域对象C> doWithDynamicMethods )。

Is it possible to unit test addTo* functions in Grails ?

thanks for your help.

解决方案

The documentation says in section 9.1:

In Grails you need to be particularity aware of the difference between unit and integration tests because in unit tests Grails does not inject any of the dynamic methods present during integration tests and at runtime.

You either have to use mockDomain(DomainClassName) in a unit test or write an integration test:

Grails decorates domain object with some Dynamic methods when the DomainClassGrailsPlugin gets setup(doWithDynamicMethods).

这篇关于Grails - 如何单元测试addTo *的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆