【发布时间】:2013-02-21 22:47:54
【问题描述】:
我正在尝试对具有需要请求对象的方法的服务进行单元测试。
import org.springframework.web.context.request.RequestContextHolder as RCH
class AddressService {
def update (account, params) {
try {
def request = RCH.requestAttributes.request
// retrieve some info from the request object such as the IP ...
// Implement update logic
} catch (all) {
/* do something with the exception */
}
}
}
你如何模拟请求对象?
顺便说一句,我正在使用 Spock 对我的课程进行单元测试。
谢谢
【问题讨论】:
标签: unit-testing grails groovy spock