I am using spock testing framework. say I have a lot of tests with similar structure like this:
def "test"() {
when:
doSomething()
then:
1 * mock.method1(...)
2 * mock.method2(...)
}
I want to move the code of "then" block to a helper method:
def assertMockMethodsInvocations() {
1 * mock.method1(...)
2 * mock.method2(...)
}
Then I can invoke this helper method to eliminate the code duplications in my test like:
def "test"() {
when:
doSomething()
then:
assertMockMethodsInvocations()
}
However method invocations cannot be captured when you put n * mock.method(...) in a helper method.
Aucun commentaire:
Enregistrer un commentaire