Testing in iOS - Part 13: Asynchronous Testing | Ray Wenderlich

This video covers some strategies when testing methods that return results over an indeterminate time.


This is a companion discussion topic for the original entry at https://www.raywenderlich.com/3530-testing-in-ios/lessons/13

Hi, Brian?
Why do you use XCTAssert(false, …) instead of XCTFail()? , and don’t use XCTAssertEqual in previous tests?

1 Like

@bdmoakley Do you have any feedback regarding this? Thank you - much appreciated! :]

As you’ve indicated, there are many different ways to achieve the same objective :slight_smile: XCTFail is certainly much cleaner but personally, I sometimes forget its there and so end up using XCTAsset(false, ...) instead. So it’s just a matter of what you are used to and what you remember. But you are right, we should have highlighted XCTFail since that’s a cleaner way to do this …

Not quite sure what you meant by not using XCTAssertEqual in previous tests though unless it’s another instance of one way vs. another. If it’s something else, could you please provide an example from a previous test?

2 Likes

I meam XCTAssert(a == b) can be replaced with XCTAssertEqual(a, b), XCTAssert(a != b) can be replaced with XCTAsserNotEqual(a, b) and so on. I agree both variants a logically the same, bit the second one a little more “verbose” ))

Hi Team, When I run the test method testInfoLoading(), the loadContent() inside InfoViewController is called twice. The loadContent() is called from testInfoLoading() and also from viewDidLoad (). Is it correct or for test purpose do I need to comment loadContent() inside viewDidLoad ().

@bdmoakley Can you please help with this when you get a chance? Thank you - much appreciated! :]

hello Brian ,

At Asynchronous Testing video you have added ( _ = vc.view) to the testInfoLoading, I did not understand why you have added it?

@bdmoakley Do you have any feedback about this? Thank you - much appreciated! :]