|
|
|
|
|
by sharkbot
5485 days ago
|
|
I find unit tests are useful due to a property they share with types, paired programming or formal specifications: you are forced to describe your program in two different "languages", and therefore have to think deeper about the problem. All of the aforementioned methods force one to code, as well as describe the intent behind the code. E.g., a unit test forces the programmer to describe the relationship of input/output, while the code describes the actual mechanism of linking input with output. Code is always the most fundamental "description" of a program, but all the methods have some descriptive power. The process of having two separate descriptions should lead to a higher quality output, as divergences between the two show a possible misunderstanding of the problem, and hence a source of bugs. |
|