Ask HN: Practical Guide to TDD?

4 points by suralind ↗ HN
I have a problem - I am really bad at writing tests. It's not that I can't write them - I always forget to..

The idea of TDD was always interesting to me and I've tried to implement it into my routine a couple of times in the past, but my experience was always the same, which was, in short, slow iteration cycle.

Can you share some practical guide/tips or an article that's good for starting out with TDD?

4 comments

[ 3.0 ms ] story [ 21.7 ms ] thread
You have to find some answer that makes you feel like the tests are worthwhile and not just busywork.

In Java I see it as an competitor to the ‘mess around with the Python CLI’ approach, In the IDE it is as quick to cycle and you can breakpoint w/ the debugger. If you have some question about how it works, you can answer the question and produce a test that is checked in.

In that way you document the API.

The book mentioned below is basically the defacto book on TDD; but if you are in the .NET ecosystem (or know how to read C# pretty well) and want to read a nice practical one I can really recommend The Art Of Unit Testing published by Manning: https://www.manning.com/books/the-art-of-unit-testing-second...

Also note that these days all popular commercial IDEs (Visual Studio, IDEA, Rider) have great builtin support for TDD (for example: automatically running tests after code changes) so manually doing things and thus slow development are a thing of the past...