Hacker News new | ask | show | jobs
by whoisjuan 852 days ago
No op, but I don’t think test-driven development resounds with everyone who writes code.

I don’t want to write tests for everything. I just want to write the ones that matter.

2 comments

That is a common misconception about TDD.

TDD is _about_ writing tests that matter, but most people think it is about writing all unit tests first.

If you are following TDD anywhere close to the way it is described, you will only be writing tests that relate to domain functionality first.

Note how it is described here, although it is turse.

https://martinfowler.com/bliki/TestDrivenDevelopment.html

The coverage metric as a goal writing style doesn't work for TDD, sorry you were exposed to that.

You are correct that model doesn't work.

> The coverage metric as a goal writing style doesn't work for TDD

Coverage is not a goal of TDD, but in practice you will have 100% coverage by following TDD as you would never have reason to write code that isn't covered by test.

Ultimately, the purpose of coverage tools is to let you know what you might have forgotten to clean up during a refactor, to help you remove what you missed.

TDD or not, why would you write tests for things that don't matter?

More importantly, why are you writing any code for things that don't matter?