vendredi 20 mai 2016

Spock: method invocation was not detected

doTip method invocation was not detected.

(I need shared for there "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