Book Image

Learning Behavior-driven development with Javascript

Book Image

Learning Behavior-driven development with Javascript

Overview of this book

Table of Contents (17 chapters)
Learning Behavior-driven Development with JavaScript
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

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 a bug).

Since the only responsibility of the web API layer is to publish the business layer over HTTP, we should not try to add any more logic here. This means that we should be agnostic about the business rules in our tests of the web API layer. So...