grails - Spock throws MissingMethodException on dynamic method that is not presented in interface -


i have groovy.lang.groovyobject interface extended. implementor class not have public constructor , contains dynamic method not presented in inteface.

i'm trying this:

def bean = stub(groovyobject) bean.getresults() >> ['result1', 'results2'] 

while invoking:

bean.getresults()  

it throw groovy.lang.missingmethodexception. in fact not carry interface contract, merely need make sure stubed object returns expected list.

also cannot stub implementor class, throw cannotcreatemockexception.

it seems have found solution myself.

instead of stub groovystub has used. allow no verification against methods of stubed class. groovyobject interface didn't work, had use groovyobjectsupport abstract class:

def bean = groovystub(groovyobjectsupport)  bean.getresults() >> ['result1', 'results2'] assert bean.getresults() == ['result1', 'results2'] 

Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -