gpt4 book ai didi

grails - 集成测试由于grails升级而开始失败

转载 作者:行者123 更新时间:2023-12-02 15:14:29 26 4
gpt4 key购买 nike

升级后,我将grails应用程序从1.2.2升级到1.3.7,一些集成测试已开始引发以下错误,“validateAndSaveList”是我正在测试的服务所使用的服务方法。这些测试在升级之前通过,如果我仅使用grails test-app -integration运行集成测试阶段,这些测试也将通过

junit.framework.AssertionFailedError: No more calls to 'validateAndSaveList' expected at this point. End of demands.



码:
import com.e.domain.*
import com.e.exception.GORMServiceException
import com.e.controller.SecurityUserCommand



class AccountServiceTests extends GroovyTestCase
{
def accountService

void testRegisterWithMinimumInfo()
{
def clinic = new Clinic(name:'clinicName')
def securityUserCommand = new SecurityUserCommand(username:'username', password:"password", confirm:"password")
def clinicUser = new ClinicUser(firstName:'fname', lastName:'lname', emailAddress:'abc@abc.com')
clinicUser.clinic = clinic
//clinicUser.securityUser = securityUser
clinic.address = new Address()
// TODO - JsecUser no longer in use
def role = new ShiroRole(name:'TEST')
//def subscription = ESubscription.findByName('Charter Member')
def subscription = new ESubscription(
name:'Charter Member',
description:'Charter Member',
periodType:'Monthly',
numPeriods:12,
amountPerPeriod:25.00,
electronicSubmissionRate:0.00,
accountingRate:0.01,
numAllowedUsers:4,
startDate: today -1,
endDate: today+1
)
subscription.save(flush:true)
if(subscription.hasErrors())
println subscription.errors
assertNotNull subscription
clinicUser.empathicCustomerProfile.subscription = subscription
def result = accountService.register(clinic, securityUserCommand, clinicUser, role)
assert result.success
assert result.clinic.id
assert result.securityUser?.id
assert result.clinicUser.id
}

堆栈跟踪
junit.framework.AssertionFailedError: No more calls to 'validateAndSaveList' expected at this point. End of demands.
at grails.test.MockClosureProxy.doBeforeCall(MockClosureProxy.java:66)
at grails.test.AbstractClosureProxy.call(AbstractClosureProxy.java:74)
at grails.test.GrailsMock$_createMock_closure1.doCall(GrailsMock.groovy:125)
at com.e.service.AccountService.register(AccountService.groovy:46)
at com.e.service.AccountService$register.call(Unknown Source)
at AccountServiceTests.testRegisterWithMinimumInfo(AccountServiceTests.groovy:53)

最佳答案

此答案来自解决注释中的问题:

您得到的异常清楚地表明,您已在服务中放置了一个模拟对象,并且该服务以未设置为处理的方式调用该模拟对象。

关于grails - 集成测试由于grails升级而开始失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6019758/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com