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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.