Error with XCTestExpectation: API violation – multiple calls made to -[XCTestExpectation fulfill]

XCTestExpectation Error

API violation – multiple calls made to -[XCTestExpectation fulfill]

I got the same error when set expectation.expectedFulfillmentCount.

Solution:

expectation.assertForOverFulfill = false

If expectation.assertForOverFulfill = true and fulfill() is called when it is already fulfilled then it throws an exception

Leave a Comment