Skip to Content
Practical Microservices
book

Practical Microservices

by Ethan Garofolo
April 2020
Intermediate to advanced
292 pages
6h 50m
English
Pragmatic Bookshelf
Content preview from Practical Microservices

Writing Tests for Autonomous Components

Basically every test, microservices or not, is a three-step dance:

  1. Set up the data for the test.
  2. Exercise the (sub)system under test.
  3. Make assertions about the results.

How does that work with autonomous components? Well, let’s consider one of the very first autonomous components you wrote back in Writing Your First Aggregator, the home page Aggregator. Its job was and still is to turn video view events into an aggregated global view count. Side by side with every bit of code in this book are test files. They’re the ones that end in .test.js. The test for the home page Aggregator is no exception. Let’s break down the basic skeleton of a test file:

 const ...
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.
Start your free trial

You might also like

Microservices in Action

Microservices in Action

Morgan Bruce, Paulo A Pereira
Microservices: Up and Running

Microservices: Up and Running

Ronnie Mitra, Irakli Nadareishvili
Kubernetes Best Practices

Kubernetes Best Practices

Brendan Burns, Eddie Villalba, Dave Strebel, Lachlan Evenson

Publisher Resources

ISBN: 9781680507782Errata Page