Test-Driven Development in Android

Jan 24 2023 Kotlin 1.6, Android 12, AS Bumblebee 2021.1.1

Part 1: Unit Tests

1. Understand Test-Driven Development

Episode complete

Play next episode

Next
Save for later
About this episode
See forum comments
Cinema mode Mark complete Download course materials
Next episode: 2. Do Red-Green-Refactor

This video Understand Test-Driven Development was last updated on Jan 24 2023

There are processes for different ways to incorporate tests into your codebase, one of which is Test-Driven Development, or TDD.

TDD is a process in which you write the tests for the code you are going to add or modify before you write the actual code.

Because it’s a process and not a library, you can apply it to any project, be it Android, iOS, web or anything else.

There are plenty of reasons for using TDD as your testing strategy.

Well-written tests describe what your code should do. From the start, you will focus on the end result. Writing these specifications as tests can keep the result from deviating from the initial idea.

When coming to a piece of code, you can look at the tests to help you understand what the code does. Because these are tests — and, again, a process — rather than a static document, you can be sure that this form of documentation is likely up-to-date.

When practicing TDD, it encourages you to pay attention to the structure of your code. You will want to architect your app in a testable way, which is generally cleaner and easier to maintain and read.

Tests ensure that your code works the way it should. Because of this, you can have greater confidence that what you wrote is “complete.”

Using a process that promotes more readable and maintainable code and that acts as self-documentation means you can spend less time trying to understand what the code does when revisiting it and use that time for solving your problem instead.

If you’re writing tests alongside your code, you’re going to have more test coverage over the code.