22 lines
1.1 KiB
Markdown
22 lines
1.1 KiB
Markdown
---
|
|
title: >
|
|
Why it's important to see the test fail
|
|
pubDate: 2023-05-06
|
|
permalink: >-
|
|
daily/2023/05/06/why-its-important-to-see-the-test-fail
|
|
tags:
|
|
- automated-testing
|
|
- test-driven-development
|
|
---
|
|
|
|
With automated testing and test-driven development, it's important to see a test fail.
|
|
If a test passes straight away, how do you know that you're testing the right thing? You could be accidentally testing a different piece of functionality, or it could be a false positive.
|
|
|
|
If the functionality already exists, do you need another test for it?
|
|
|
|
When you see a test fail, you know that the functionality hasn't been implemented, that you're testing the correct thing, and you have a clear goal to work towards.
|
|
|
|
If you're fixing a bug, writing a test and seeing it fail verifies the bug exists and that, once the bug is fixed, the test will pass.
|
|
|
|
Usually, you can anticipate why a test will fail as it evolves and know when it will pass. If a test passes before I expect, I'm immediately sceptical and will look into why rather than assuming it passed for the right reasons.
|