Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Unit testing a closure with Spock  RSS feed

 
Red Maxwell
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How would one unit test code within a closure using Spock?

// example groovy code

def someObject
def someOtherObject

def x = someCollection.collect{ item ->
someObject.doSomething(item)
}

// example Spock test snippet


then:
1 * someObjectMock.filter() >> foo
2 * someOtherObjectMock.find() >> bar

So here's the question: how to test the someObject.doSomething(item) in the above closure?
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!