Every system has its specific building blocks, and test-driven development is no different. In this video, explore the definition of a unit test, how we use them, and the analytical thinking is necessary to build a strong test suite.
- Test-driven development aims to solve a critical problem: increasing application complexity and the inefficiency of human testing. Now, in any good development system, we need great tools, and that's where unit tests come in. At this level of abstraction, an analogy is very useful when learning a new skill, so let's start with that. A test suite is like a living organism. It has different functional parts which are made up of smaller and smaller functional blocks, which in turn are made up of atoms at the most basic level.
In this case, individual unit tests are the atoms, the smallest level of functionality in the test suite. The test suite functions like your application's immune system. The stronger it is, the less likely your app is to break down. We'll carry this analogy through to the conclusion when we talk about code coverage at the end of the course, so keep it in the back of your mind when you get stuck. Analogies aside, unit tests have a specific definition. Each individual unit test is only concerned with testing one thing at a time.
This can be anything from variable initialization and interface configuration to asynchronous API calls and custom protocols. Whatever your unit tests are testing, the goal is always to prove that your code is working the way you want it to and not the way you assume it will. Defensive programming like this will give you greater confidence in your code base as it grows. Think of your unit tests like helper minions. You tell them what to test and when and let them do the work. You can call on them anytime.
They don't sleep. And together they make up a very powerful automated testing system for your application.
- What is test-driven development?
- Creating and expanding a data model
- Creating a manager class
- Testing class methods
- Checking for duplicates
- Testing table views
- Mocking cells
- Testing cell selection
- Assembling the app