The following article presents my take on unit testing iOS apps.
Tests follow FIRST approach:
- Independent/Isolated - no shared state
- Repeatable - same results every time the test is run
- Self-validating - fully automated with “pass” or “fail” result
- Timely - e.g. written on time, ideally using test-driven development (TDD)
Tests are automated. Run often. Preferably on each commit or pull request to quickly catch regressions.
- GitHub Actions + Fastlane tools
- Xcode Cloud - I see it as a way to go although currently it’s not as configurable as GitHub Actions + Fastlane
- Back in the days I used physical Mac and Jenkins :)
Test builds are available for testing and demoing.
- TestFlight - this is the key to transparency. Product managers should always have access to test builds. Preferably, when working in scrum, builds with Sprint Increment are available for download before the Sprint Review.
This answers 2 questions:
What are we testing? How much are we testing?
- Code coverage - strive to test all the code lines (but use common sense)
- Test coverage - test every functional requirement. This often requires manual testing or automated UI testing.
- Compatibility coverage - test different iOS versions, on different devices
- Non-functional testing - performance, security, usability etc.
Examples of some testing frameworks I tried in the last decade: