I'm testing a class that has a delegate. The delegate is the test class of course, and from the implementation of the delegate methods I call different expectations:
- (void)mySuccess {
[self.successExpectation fulfill];
}
- (void)myFail:(NSError *)error {
[self.failExpectation fulfill];
}
How can I tell from the test class which expectation called 'fulfill'?
This isn't true way expectations are supposed to be used. You should queue up an expectation for something to happen, which then may or may not be fulfilled. The test will fail if your expectation is not met, which means that you don't need to track whether a 'fail' or 'success' expectation has been met. You can derive success or failure from a single expectation, so you should use expectations in that manner, if that's possible with your code.
For example, your mySuccess method should call fulfill on your expectation, but myFail should do nothing (resulting in your expectation not being fulfilled) and/or raise an error or XCTFail().