I think there are seven reasons why writing tests during software development is a good practice for me. Here they are. (There is some overlap in the reasons, and some might agree with all the points, but still find a different classification made better sense.)
- Correctness. Writing tests means that the code that I write is more correct. There are fewer errors, bugs, or unwanted behaviors. I think this is fairly universally accepted, so I will not belabor the point.
- Shortened feedback loop. Writing tests creates a much improved feedback loop compared to running an application and inspecting its outputs. Writing a test is almost like being in a REPL, except I am in an editor and so everything I do can easily be saved. (I know more advanced programmers know how to run REPLs within their editors. Wizards.) I think that Jane Street's Jenga/Emacs integration is particularly shiny and sweet in this regard.
- It's a free client. Suppose I'm writing a module to provide frobulation. It's likely that I have onl