Exploring the API under test
The first step in writing effective API tests is to explore the API under test. This can be done both by reading the API documentation and by playing around with it. This way, you can already get a feel for how the interfaces are structured and where there might be sources of errors that should be tested automatically.
The JSONPlaceholder API
We will use the JSONPlaceholder API for this chapter. This is a publicly available mock API that simulates a real API. Unlike a real REST application, the data here is not generated dynamically, but fixed static data is returned per endpoint. This makes it ideal for illustrating some Karate concepts. Plus, for now, we don’t have to worry about dealing with mutable return values that are harder to check since they are more unpredictable.
Later in this chapter, we will see how we can still make checks against server-side responses without knowing exactly what values they include.
Mock APIs versus real...