【发布时间】:2014-09-22 21:12:44
【问题描述】:
我有以下服务:
class MyMainService {
def anotherService;
def method1("data") {
def response = anotherService.send("data")
}
}
anotherService 是在 grails resources.groovy 中定义的一个 bean
我想通过模拟 anotherService.send("data")
对 MyMainService 中的 method1 进行单元测试如何模拟 anotherService bean 及其 send() 方法的返回值并注入到我的 MyMainServiceSpec 测试类中? p>
我正在使用 grails 2.3.8。
谢谢。
【问题讨论】:
标签: unit-testing grails grails-2.0 grails-services