Make it easier to add more stable tests to your suite

When translating a Test Case (TC) to an automated script, you should think very carefully about what exactly you’re testing, to avoid the need of fixing the test every time a single label changes.

Let’s say you have a TC to assert a search-result flow:

TC123 - Validate Search TermTest Steps: 
1. Open app
2. Type "Xcode" on search field
3. Tap "OK" button
Expected Result:
3. The app should go to Results View with "Result for Xcode" as title.

Fragile Solution

let app = XCUIApplication()
app.textFields[“Search”].typeText(“Xcode”)
app.buttons[“OK”].tap()
XCTAssert(app.staticTexts[“Result …


I will show you a way to identify what you should test and some concepts to make your life a little easier when writing tests.

At some point in my career I knew how important unit tests were, but I didn’t know how to test my code. Many have faced the same issue. We read articles on how to start, but still, it’s hard to apply what we’ve learnt to our own code. We usually don’t have those functions that just sums up two parameters and returns the result, and we see it in many examples out there. …


Let’s write a decoupled code and by using composition even be able to test our ViewController! 😱

When I had to write a QR code scanner app I had never used AVFoundation before. So I followed the usual script: I read a bit of documentation, went through some tutorials, and applied the new knowledge to my needs. The problem with the common way out there is it makes the ViewController conform to one more protocol. Thus, it adds another responsibility!

I’ll show you a better approach using a simple app as an example.

After reading a QR code the app can either show a card or an error if it doesn’t know the code

The first ViewController needs a way to…

Daniel Souza

iOS Developer, learning and sharing in the process

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store