Testing Microservices with Mountebank
Brandon Byars
  • December 2018
  • ISBN 9781617294778
  • 240 pages
  • printed in black & white

A complete and practical introduction to service virtualization using Mountebank, with lots of usable examples.

Alain Couniot
Testing Microservices with Mountebank is your guide to the ins and outs of testing microservices with service virtualization. The book offers unique insights into microservices application design and state-of-the-art testing practices that will deepen your microservices skills and improve your applications.

About the Technology

Even if you lab test each service in isolation, it’s challenging—and potentially dangerous—to test a live microservices system that’s changing and growing. Fortunately, you can use Mountebank to “imitate” the components of a distributed microservices application to give you a good approximation of the runtime conditions as you test individual services.

About the book

Testing Microservices with Mountebank introduces the powerful practice of service virtualization. In it, author Brandon Byars, Mountebank’s creator, offers unique insights into microservices application design and state-of-the-art testing practices. You’ll expand your understanding of microservices as you work with Mountebank’s imposters, responses, behaviors, and programmability. By mastering the powerful testing techniques in this unique book, your microservices skills will deepen and your applications will improve. For real.

Table of Contents detailed table of contents

Part 1: First Steps

1 Testing Microservices

1.1 A microservices refresher

1.1.1 The path towards microservices

1.1.2 Microservices and organizational structure

1.2 The problem with end-to-end testing

1.3 Understanding service virtualization

1.3.1 Test-by-test setup using an API

1.3.2 Using a persistent data store

1.3.3 Record and replay

1.4 Introducing mountebank

1.5 The service virtualization tool ecosystem


2 Taking Mountebank for a Test Drive

2.1 Setting up the example

2.2 HTTP and mountebank: a primer

2.3 Virtualizing the Product Catalog Service

2.4 Your first test


Part 2: Using mountebank

3 Testing Using Canned Responses

3.1 The Basics of Canned Responses

3.1.1 The Default Response

3.1.2 Understanding how the default response works

3.1.3 Changing the default response

3.1.4 Cycling through responses

3.2 HTTPS imposters

3.2.1 Setting up a trusted HTTPS imposter

3.2.2 Using mutual authentication

3.3 Saving the responses in a configuration file

3.3.1 Saving multiple imposters in the config file


4 Using Predicates to Send Different Responses

4.1 The basics of predicates

4.1.1 Types of predicates

4.1.2 Matching object request fields

4.1.3 The deepequals predicate

4.1.4 Matching multi-valued fields

4.1.5 The exists predicate

4.1.6 Conjunction Junction

4.1.7 A complete list of predicate types

4.2 Parameterizing predicates

4.2.1 Making case-sensitive predicates

4.3 Using predicates on JSON values

4.3.1 Using direct JSON predicates

4.3.2 Selecting a JSON value with JSONPath

4.4 Selecting XML values


5 Adding record / replay behavior

5.1 Setting up a proxy

5.2 Generating the correct predicates

5.2.1 Creating predicates with predicateGenerators

5.2.2 Adding predicate parameters

5.3 Capturing multiple responses for the same request

5.4 Ways to replay a proxy

5.5 Configuring the proxy

5.5.1 Using mutual authentication

5.5.2 Adding custom headers

5.6 Proxy use cases

5.6.1 Using a proxy as a fallback

5.6.2 Converting HTTPS to HTTP


6 Programming mountebank

6.1 Creating your own predicate

6.2 Creating your own dynamic response

6.2.1 Adding state

6.2.2 Adding async

6.2.3 Deciding between response vs. predicate injection

6.3 A word of caution: security matters

6.4 Debugging tips


7 Adding behaviors

7.1 Understanding behaviors

7.2 Decorating a response

7.2.1 Using the decorate function

7.2.2 Adding decoration to saved proxy responses

7.2.3 Adding middleware through shellTransform

7.3 Adding latency to a response

7.4 Repeating a response multiple times

7.5 Replacing content in the response

7.5.1 Copying request data to the response

7.5.2 Looking up data from an external data source

7.6 A complete list of behaviors


8 Protocols

8.1 How protocols work in mountebank

8.2 A TCP primer

8.3 Stubbing text-based TCP-based RPC

8.3.1 Creating a basic TCP imposter

8.3.2 Creating a TCP proxy

8.3.3 Matching and manipulating an XML payload

8.4 Binary support

8.4.1 Using binary mode with Base64 encoding

8.4.2 Using predicates in binary mode

8.5 Virtualizing a .NET Remoting service

8.5.1 Creating a simple .NET Remoting client

8.5.2 Virtualizing the .NET Remoting server

8.5.3 How to tell mountebank where the message ends


Part 3: Closing the Loop

9 Mountebank and continuous delivery

9.1 A continuous delivery refresher

9.1.1 Test strategy for continuous delivery with microservices

9.1.2 Mapping your test strategy to a deployment pipeline

9.2 Creating a test pipeline

9.2.1 Creating unit tests

9.2.2 Creating service tests

9.2.3 Balancing service virtualization with contract tests

9.2.4 Exploratory testing


10 Performance testing with mountebank

10.1 Why service virtualization enables performance testing

10.2 Defining your scenarios

10.3 Capturing the test data

10.3.1 Capturing the responses

10.3.2 Capturing the actual latencies

10.3.3 Simulating wild latency swings

10.4 Running the performance tests

10.5 Scaling mountebank


What's inside

  • The core concepts of service virtualization
  • Testing using canned responses
  • Programming Mountebank
  • Performance testing

About the reader

Written for developers familiar with SOA or microservices systems.

About the author

Brandon Byars is the author and chief maintainer of Mountebank and a principal consultant at ThoughtWorks.

placing your order...

Don't refresh or navigate away from the page.
print book $34.99 $49.99 pBook + eBook + liveBook
Additional shipping charges may apply
Prints and ships within 3-5 days
Testing Microservices with Mountebank (print book) added to cart
continue shopping
go to cart

eBook $27.99 $39.99 3 formats + liveBook
Testing Microservices with Mountebank (eBook) added to cart
continue shopping
go to cart

Prices displayed in rupees will be charged in USD when you check out.

FREE domestic shipping on three or more pBooks