Summary
The naïve approach of testing both the web API layer and the business layer is not usually a good idea. We can run into problems such as slow tests, difficulties in debugging the tests, excessive complexity, and so on. Instead, it is better to slice the system into two layers: the web API, which is responsible for publishing the business logic over the Web, and the business layer, which is responsible for implementing the business rules themselves.
If both layers are developed by the same team, then we can assume that the business layer will always fulfill its contract. If not, it will be better to add new scenarios to check whether the web layer reacts in a sensible way if the business does not comply with its contract (that is, it has ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access