Test-Driven Development in Android

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

Part 1: Unit Tests

02. Do Red-Green-Refactor

Episode complete

Play next episode

About this episode
Leave a rating/review
See forum comments
Cinema mode Mark complete Download course materials
Previous episode: 01. Understand Test-Driven Development Next episode: 03. Build Unit Tests
Transcript: 02. Do Red-Green-Refactor

In this episode, you will learn the basics of the TDD process while walking through the Red-Green-Refactor steps. Red-Green-Refactor describes the steps that you follow when practicing the TDD process.

The first step is the red step. Here you start by writing a failing (red) test. This is for any new feature, behavior change, or bug fix that doesn’t already have a test for what you will be doing. You only write the tests and the bare minimum code to make it compile. Make sure you run the test and see it fail.

The second step is the green step. It involves writing the minimum code to make the test pass. You’re not worried about making it pretty or adding any additional functionality at this step.

The last step is refactor. This is when you prettify your code and make any needed changes to make sure it is clean. You know that your changes are safe and correct as long as your tests stay green.

Lets put the red green refactor steps into practice!