1

In general it makes sense to me to unit test everything besides glue classes which have no logic. They often catch mistakes and code smells even at the time of writing let alone protecting you from regressions later on.

What I'm less sure about is higher-level tests. In particular for traditional MVC web-apps you often have three levels of granularity:

  • model tests are like unit tests and they test the business logic of a specific module abstracting away its dependencies
  • controller tests simulate an http request
  • functional or end-to-end tests use a programmable browser through selenium or similar to simulate a user clicking in his web browser

The trade-off is between complete coverage (write only end-to-end tests for every single edge case) and succinctness (model tests are much simpler to write).

What are some good heuristics for knowing how many cases to test at the controller and functional level?

  • functional tests are the easiest ones to show & explain to the business folks – Dan Pichelman Mar 3 '16 at 17:18