WWDC Notes

Engineering for Testability

Show Apple's description.
Unit testing is an essential tool to consistently verify your code works correctly. Discover techniques for designing the code of your app so that it can be easily tested. Find out the best practices for developing a test suite that evolves with your app and scales as your app grows.
  • Separate Logic and Effects
  • Pyramid of Tests (between UI and Unit tests there’s integration tests)

UI Tests Tips

Store parts of queries in variables.

Instead of this:

Write this:

Wrap Complex queries in utility methods

Instead of this:

Write this:

Then create a GameApp class:

And get this:

Now it’s super easy to change the configuration, and if in the future we have more settings we just need to update the GameApp class

In the configure settings func we can also write this:

So when the test run we can have more insights of what’s going on:

Missing anything? Corrections? Contributions are welcome 😃

Related

Written by

zntfdr

Federico Zanetello

Federico Zanetello is an iOS Engineer with strong passion for Swift, minimalism, and design. When he’s not busy automating things, he can be found writing at fivestars.blog and/or playing with the latest shiny toys.