13 BDD and executable specifications for microservices and APIs

 

This chapter covers

  • API and Microservice-based architectures and how to test them
  • The difference between broader user journey requirements and more specific business rule requirements, and how user journey requirements can often be automated using API interactions
  • Using RESTAssured to interact with REST APIs
  • Using JSONPath to query the responses returned by REST API calls

Thus far we have focused on automating tests that exercise the user interface. But, as we discussed in chapter 10, user interface tests shouldn’t be the only tool in your automated acceptance testing toolbox. It’s important to know when to use them and when to look for alternative strategies. In this chapter, you’ll learn about other ways to automate your acceptance tests that don’t involve exercising the user interface.

13.1 APIs and how to test them

13.2 Defining a feature using a web UI and a microservice

13.2.1 Understanding the requirements

13.2.2 From requirements to executable specifications

13.3 Automating acceptance tests for microservices

13.4 The microservice architecture under test

13.4.1 Preparing the test data

13.4.2 Performing a POST query: Registering a Frequent Flyer member

13.4.3 Querying JSON responses with JSONPath

13.4.4 Performing a GET query: Confirming the frequent flyer address

13.4.5 Partial JSON Responses: Checking the new Frequent Flyer account details

13.4.6 Performing a DELETE query: Cleaning up afterward

13.5 Automating more granular scenarios and interacting with external services

13.6 Testing the APIs or testing with the APIs

Summary