テスト対象コードにスリープが含まれていると、テストに時間が掛かってしまいます。いわゆるスローテストの問題です。そのため、スリープを無害なモックに置き換えることでテストの時間を短くする工夫がよく行われます。 Groovyでは meta class でスリープメソッドを置き換えることが可能です。 例 こんなメソッドがあるとします。 class CommandLifecycleManager { def commands = [] as List<Command> void waitForPending(Closure closedCommandHandler) { def pendingCommands = new ArrayList<Command>(commands) while (!pendingCommands.empty) { def closedCommands = pending