JGWeissman comments on Coding Rationally - Test Driven Development - Less Wrong

25 Post author: DSimon 01 October 2010 03:20PM

You are viewing a comment permalink. View the original post to see all comments and the full post content.

Comments (82)

You are viewing a single comment's thread. Show more comments above.

Comment author: JGWeissman 29 September 2010 05:43:44PM 1 point [-]

Good example:

You want a program that can invert matrices. You write a test that calls the program, passing it a matrix. The test multiplies the original matrix with the result from the invert program, and verifies that the product is unity.

This is a good case to use TDD because the test is simpler than the program you are testing.

Also, an important part is to test edge/corner cases. In the matrix example, there should be a test that passes the invert program a singular matrix, and validates that it returns an appropiate error.