samedi 21 mai 2016

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)
}
}

Aucun commentaire:

Enregistrer un commentaire