Verify Spock mock with specified timeout

前端 未结 4 449
灰色年华
灰色年华 2021-01-04 21:20

In Mockito there is option to verify if mock method has been called, and specify timeout for this verification (VerificationWithTimeout), for example:



        
4条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-04 22:04

    There is no equivalent in Spock. (PollingConditions can only be used for conditions, not for interactions.) The closest you can get is to add a sleep() statement in the then block:

    when:
    ...
    
    then:
    sleep(200)
    (1.._) * mock.baz()
    

提交回复
热议问题