Bad Test, Bad

bob.js on July 30, 2019

These tests should never have been written. They provide no or little value. Testing code as been described as an "art form." It is, but it shou... [Read Full]
markdown guide

Very well written. I loved how you gave bad examples and proceeded to correct them.

And you raise some good points too. I found many testing patterns I learned from experience that I wish someone had told me about when I was just getting started with TDD. Especially the one about not giving too much thought to the DRY principle during tests.


One of the hardest parts I found about TDD was knowing exactly what to test.

You start off thinking you must test every little bit of code, but this just creates major overhead and often quite brittle tests. I've come to the conclusion that it's better to think about it as input/output.

Only testing for what's coming in and what's going out. The internals of how we get that expected output aren't necessary to test. This has helped greatly when writing tests and hopefully is correct.

Other than that, TDD has really helped to encourage keeping functions simple and modular. When something becomes (or looks like it's becoming) difficult to test, it often means the function is becoming too verbose and should be split up into smaller more manageable/testable pieces.


I was in the same boat and recently have been mentoring an organization on testing ... prompting this article. Thanks!

code of conduct - report abuse