The traditional way of testing software encompasses a long phase of manual testing at the end of the software development cycle. This approach has been proven ineffective because manual testing is a long and non-scalable process, and also because the more efficient way is to have short release cycles—two or three weeks—and have a part of the iteration dedicated to the manual testing which, simply isn't affordable. Also, as developers, we realized that the best way of making our code testable is to write simple, granular, and automatic tests while we are still in development. This method, called Test-Driven Development (TDD), was made famous by Kent Beck in his work on Extreme Programming, a revolutionary software programming methodology, revolutionary for its time.
It's based on writing the tests before writing the production code, such as tests that must run automatically using a testing framework. The first framework for doing this was called SUnit because it was for a programming language called Smalltalk. We could define a unit such as a chunk of software that implements a functionality. Using SUnit, the developer could implement a test to verify that functionality automatically, without the need of verifying it manually. Even though TDD was rarely used in the iOS community until a few years ago, it is currently widely accepted as a mainstream practice. There are several testing frameworks in Swift or Objective-C that can be used in Swift code, however, Apple provides a good solution for it as a default in Xcode, called XCTest. We'll start exploring it in this section.