vendredi 26 mars 2021

What's the difference between calling expectation(description:) and creating a new XCTestExpectation instance in an XCTestCase? iOS Swift

In the Apple Docs on expectation(description:), it states that this function "Creates a new expectation with an associated description".

This seems like creating a totally new instance, but in the last answer of this SO Post, it says it's kinda "shared" (not sure if he is correct or not) and when I have a test function calling expectation(description:) multiple times (and waiting for them multiple times, not in a single call to wait(for:timeout:)) I got some failures on our CI server (it worked fine on local) but when replaced with a basic call to the init(:description) of XCTestExpectation, both the local and the CI server worked fine. This lead me to think maybe the docs are misleading on this. I don't think Apple would add the function expection(description:) to XCTestCase just for the sake of being shorter to write than XCTestExpectation(description:) so it might actually be logical that there's a difference between them.

Or maybe it's Apple, and you'd never know what's logical or not.

Are they totally the same?

Aucun commentaire:

Enregistrer un commentaire