Spock - extracting interactions to method

后端 未结 1 869
北海茫月
北海茫月 2021-02-20 16:04

The spock documentation points out that you can extract assertions of then block to other method and add assert keyword before each assertion.

相关标签:
1条回答
  • 2021-02-20 16:19

    Turns out you can. You have to wrap helper method call with interaction:

    then:
        interaction {
             helperMethod()
        }
    

    and then you can put interactions in a helper method like that:

    def helperMethod() {
        1 * someObj.getInt() >> 2
    }
    

    I did it other way around (wrapped helper method body in interaction), that's why it did not work

    0 讨论(0)
提交回复
热议问题