Spockの PollingConditions が便利だったのでメモです。 PollingConditions は条件を満たすかタイムアウトになるまで評価を繰り返してくれます。E2Eテストで別スレッドでサーバを起動してサーバがreadyになるまで待つといった場合に便利です。 import spock.lang.Specification import spock.util.concurrent.PollingConditions class ServerSpec extends Specification { def "server should listen on given port"() { given: '空きポートで待ち受けるWebサーバを生成する' int port = pickUpFreePort() def server = new Server(port) when: