Spock间谍导致" MethodMissingException"

时间:2014-03-19 21:02:18

标签: groovy spock

我正在尝试使用Spock Spy进行部分模拟。 这是有效的代码:

setup:
Bulk bulk = new Bulk()
bulk.setApi(stub)           
when:
bulk.updateHeldBounsedSubscribers(subscribers, bounceEvents)

以下是不起作用的代码:

setup:
Bulk bulk = Spy(Bulk)
bulk.getSubscribersByKeys(_) >> subs
bulk.setApi(stub)           
when:
bulk.updateHeldBounsedSubscribers(subscribers, bounceEvents)

它产生以下异常:

groovy.lang.MissingMethodException: No signature of method: com.otpp.email.BulkEmailDownloader$$EnhancerByCGLIB$$8227f19f.updateHeldBounsedSubscribers() is applicable for argument types: (java.util.ArrayList, java.util.LinkedHashMap) values: [[com.exacttarget.wsdl.partnerapi.Subscriber@57a41eae], ...]
at com.otpp.email.DownloaderUnitTests.updateHeldBounsedSubscribers test with mocked API objects(DownloaderUnitTests.groovy:223)

1 个答案:

答案 0 :(得分:1)

该方法是私密的。 我将其更改为受保护并且有效。