Reputation: 1724
I would like to Verify that an expected method is called with the correct parameters in Swift in unit-testing. This was very easily done in Objective-C using the OCMock framework. You could do a combination of partialMocking and running OCMExpect/Verify to assert code paths with the right parameters were being called. Any idea how to do something like this in Swift?
Upvotes: 1
Views: 646
Reputation: 20980
Swift doesn't support reflection, so traditional mocking libraries aren't feasible. Instead, you need to create your own mock. There are at least two approaches to do this.
Hand-crafted mocks aren't hard. You want to
It is a lot of boilerplate. There are libraries out there that can auto-generate this code.
Upvotes: 1