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?

closed as too broad by gnat, user40980, l0b0, Bart van Ingen Schenau, Robert Harvey Mar 3 '16 at 19:20

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

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