Turbo-Boost Your Unit Tests in Xcode and Swift
Shortcuts and best practices
Unit tests are just as important as your normal programming code. Getting them right is important. Doing a good job is important. Get this right, do.
Difficulty: Easy | Normal | Challenging
Prerequisites
- Some basic understanding of functions and methods in Swift.
- Some String interpolation comes up later, but you can skip that bit.
- Some experience of setting up classes in Swift would be beneficial.
Terminology
Unit testing: Software testing where individual units of the software are tested.
Before we start
You should be writing with a test-driven mindset. This means you should think about writing tests first. Although this sounds like it might slow you down, there is actually reams of evidence that writing tests first not only makes you a better programmer but a faster one too. An alternative to full test driven development is test-driven bug fixing where you use a similar technique to solve bugs within your code. As ever, the best person to decide what strategy to use for your code is you.