Search code examples
groovyspock

Spock Mock, return "x" when method is called no matter what variables are passed to method


So I have a method that has a few variables in its signautre like this public PageLinksVM mapLinks(URI requestUrl, Integer offset, Integer limit, Integer total)

If it had no variables on the input I would do the following

 def:

object.mapLinks()>> returnedObject

How do I do this when the method has inputs and i Want to return no matter what is passed to the method?


Solution

  • You can use *_ to allow any number of any input arguments.

    def:
      object.mapLinks(*_)>> returnedObject
    

    Here is the Spock documentation on argument contraints.