SwiftyMocky icon indicating copy to clipboard operation
SwiftyMocky copied to clipboard

Closed set of methods called on a mock

Open bonkey opened this issue 4 years ago • 1 comments

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:

  1. Check if a complex flow doesn't do too much under the hood
  2. 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)))

bonkey avatar Jun 03 '21 14:06 bonkey

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 :)

g-amichnia avatar Jul 06 '21 15:07 g-amichnia