6 Automating web API tests

 

This chapter covers

  • What automation can and cannot do
  • The risks automation can help mitigate
  • How to set up automation for API testing
  • How to build a series of automated API checks

According to Global Market Insights, in 2019, the “automation testing market” was worth $19 billion, with projections that it could grow to $36 billion by 2026, which reflects the demand for automated testing. As teams are expected to deliver faster, more complex products, the desire to implement automated testing as a testing strategy has increased. Unfortunately, this automation gold rush comes with many misconceptions about what it can achieve and its value, potentially misleading teams into a false sense of security about the product they’re delivering and its quality.

The issue, though, lies not in the tools themselves but the perception of how they can be used. When automation is used correctly, it can be a major asset to a team’s testing strategy. But it requires us to know the limitations and advantages of using automation in a test strategy, as well as understanding how to implement automation in a clean and maintainable manner. So for this chapter, we’ll begin by discussing how to get the most out of automation before exploring how to implement our own automation.

6.1 Getting value from automation

6.1.1 The illusion of automation

6.1.2 Automation as change detection

6.1.3 Letting risk be our guide

6.2 Setting up a Web API automation tool

6.2.1 Dependencies

6.2.2 Structuring our framework

6.3 Creating automated API checks

6.3.1 Automated check 1: A GET request

6.3.2 Automated check 2: A POST request

6.3.3 Automated check 3: Combining requests

6.3.4 Running your automated tests as integration tests

6.4 Utilizing automation in our strategy

Summary