TDD in existing projects

You most probably already have projects that have been implemented without any tests. It is much harder to add tests to an existing project than it is to write them first. When you don't keep in mind that you need to write a test for code sometime in the future, the code itself will become hard to test. It is often easier to tie the different parts of the app together, instead of keeping them separated with a clear and defined interface to each other. As a result, it becomes hard to separate microfeatures in order to test them with unit tests. In addition to this, testing methods with many side effects can be cumbersome to deal with.

When writing the tests initially, you will automatically think about the tests. The ...

Get Test-Driven iOS Development with Swift 4 - Third Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.