oliverdavies.uk/source/_daily_emails/2023-05-08.md

17 lines
692 B
Markdown
Raw Normal View History

2024-01-03 20:00:00 +00:00
---
title: >
2024-02-07 20:01:19 +00:00
Only write enough code to get a failing test
2024-01-03 20:00:00 +00:00
pubDate: 2023-05-08
permalink: >-
2024-02-07 20:01:19 +00:00
archive/2023/05/08/only-write-enough-code-to-get-a-failing-test
2024-01-03 20:00:00 +00:00
tags:
2024-02-07 20:01:19 +00:00
- automated-testing
- test-driven-development
2024-01-03 20:00:00 +00:00
---
Instead of writing a whole test and then attempting to make it pass, only write enough code to get the test to fail.
This could be by starting with a failing assertion that is fixed with a hard-coded value and then iterating on the test to introduce the next failure before repeating the process.
This allows you to keep the feedback loop small and not write more code than is needed, to focus on the objective of the test, and not code yourself into a corner.