作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
在集成测试中,我正在使用groovy模拟功能来模拟如下所示的服务方法:
def mock = new groovy.mock.interceptor.MockFor(PaymentService)
mock.demand.processPayment(){ a, b, c-> ['status': true, 'approved': true, 'tresponse': new TransactionResponse(amount: total.toBigDecimal(), transactionId: "4234234555", saleId: Sale.last().id, responseCode: "1", responseReasonCode: "1", responseReasonText: "approved", authorizationCode: "asdasd", paymentMethod: "CC", transactionType: "auth_capture", cardCodeResponse: "P").save(flush: true)]}
mock.use{
controller.paymentService = new PaymentService()
populateReceiptParams(total)
controller.receipt()
}
junit.framework.AssertionFailedError: No call to 'getMergedSale' expected at this point. Still 1 call(s) to 'processPayment' expected.
at PaymentController.cart(PaymentController.groovy:296)
at PaymentController.receipt(PaymentController.groovy:1096)
paymentService.getMergedSale([sessionAuth, userAuth])
最佳答案
So does this mean that the mocked method which is processPayment must be called first before getMergedSale?
getMergedSale
的模拟实现。
关于grails - 目前尚无人调用。仍然有1个调用预期错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55489285/
我是一名优秀的程序员,十分优秀!