SwiftyMocky
SwiftyMocky copied to clipboard
Closed set of methods called on a mock
I couldn't find it anywhere: is it possible to define a precise set of methods called on a mock and no others?
I'd expect an interface for that like that:
public func verify(_ method: [Verify], ordered: Bool, file: StaticString = #file, line: UInt = #line)
I see two use cases for that:
- Check if a complex flow doesn't do too much under the hood
- If changes introduced later in code doesn't break any existing flow
Without it, it requires:
Verify(mock, 0, .methodNotToBeCalled1())
Verify(mock, 0, .methodNotToBeCalled2())
Verify(mock, 0, .methodNotToBeCalled3())
Verify(mock, 1, .methodToBeCalled(param: .value(1)))
Verify(mock, 1, .methodToBeCalled(param: .value(2)))
I see no issue. Will recheck the api (maybe variadic params?) but I think I will propose something with similar behaviour. Expect rather a VerifyStrategy enum than ordered Bool :)