Skip to main content
edited tags
Link
tim_yates
  • 171.7k
  • 29
  • 359
  • 354
Source Link
Arthur
  • 1.2k
  • 4
  • 24
  • 50

Spock does not detect method invocation

Spock does not detect doTip method invocation

(I need shared for some "where" blocks.)

Used latest groovy and spock.

Why this code is wrong?

How fix it?

import spock.lang.Shared import spock.lang.Specification class Test extends Specification { def controller @Shared String g = "" @Shared def tip = Mock(Tip) def "test"() { controller = new TController(tip: tip) when: controller.transform(g) then: 1 * tip.doTip(_) } } class Tip { def doTip(String f) {} } class TController { Tip tip def transform(String g) { tip.doTip(g) } }