I have been reading the following Uncle Bob post on TDD. He explains that there are cases where TDD is not needed. Mainly in a case where your tests and code are both very specific, and your code is not tending to more general algorithms.He suggests that logic should be TDDed, and everything that isn't logic should be added to a humble layer. For example CSS. Testing that a css class is 5px would require both the test and code to have 5px hardcoded into both. While tests get more specific, the css will not get more generic, in fact it too will get more specific.Remember the TDD rule: As the tests get more specific, the code gets more generic. Every new test case makes the test suite more constrained and more specific. To make the new test case pass, the programmer strives to make the production code more general, not more specific.......Indeed, you could write a program that reads the CSS and writes the tests. Such tests add very little value, and they certainly aren't written first.This makes sense, but I have come across a case where the same logic could apply, but not sure if I've taken the example in the post too far.I have a controller class which I have applied TDD to. The classes method returns a view name as a response. Methods may pass different variables into the view, but the view name always remains the same.The view name will be hardcoded into the controller, and into the test. Is it therefore a pointless test (as per the CSS example) ? As the tests get more specific for my controller, there will never be a case where I can somehow end up making the code that outputs the view name more generic: it will always be hardcoded to return a specific view name.If it is a pointless test, where should I place this 'humble' code? If the controller is seen as a class that has logic (and therefore needs TDD) and the output of a specific view name is 'humble', how do I account for this in my controller?Note: When i say the controller has 'logic' I mean that it has TDD testable logic e.g. a controller will pass user data to a model, the controller therefore needs tests that ensure it is passing the correct data to a model.
Should I TDD correct view returned from controller?
tdd