DEV Community

Discussion on: How to test software effectively

Collapse
 
mindplay profile image
Rasmus Schultz

There's nothing inherently wrong with writing unit tests - as long as you're prepared to throw them away, as soon as they get in the way.

Yes, unit tests have a tendency to test implementation details - during development, that's exactly what I want. Especially in quirky languages like JavaScript, where the language itself doesn't guarantee much of anything. But I feel like unit tests are often a faster and safer way to get a working function.

Once you have functional or E2E tests in place, yes, the unit tests are often redundant - you can either throw them away, as soon as the next layer up is covered by tests, or you can keep them around until they get in the way of refactoring.

I wouldn't discourage anyone from writing them though. Especially on big projects, proving that you have a bunch of working units, before you begin integrating them, definitely has value.