What am I Testing?

This morning I read thisĀ post by Jimmy Bogard on Los Techies. To me he seems to be saying why write tests for the three lines of code in a controller action, when the real work, the important stuff if you like, is in his PostsRepository? The best point he makes is ask the question ‘What am I testing?’. Am I writing tests for the sake of writing tests or do they have a real purpose.

Now, for me I’d write basic tests for this controller. As one of the commentators says the real value for those tests are in four years time. Although there isn’t a lot of functionality in the controller method, there are still assumptions or rather expectations. When the behaviour of the controller action is changed, then we want tests that tell us whether our expectations are being met.

A lot of this seems a bit ‘airy-fairy’ and arguing the toss, but I’m hoping I get a point across. Tests in any discipline, whether it be engineering, science, medicine or software are there for a purpose. Is this product working as I expect?