我想重寫方法調用groovy sql類,我能做到這一點。但我需要有不同的實現基於順序。Groovy metaclass基於調用順序添加多個方法不模擬
Sql.metaClass.call = {String sql, List params, Closure c -> c(mockResultSet)} //first time should call this method
Sql.metaClass.call = {String sql, List params, Closure c -> c(expectedLookupId)} //second time should call this method.
可能重複http://stackoverflow.com/questions/26737268/mock-out-return-of-a-method - 僅在調用中的數量) – dmahapatro