Book Image

Writing API Tests with Karate

By : Benjamin Bischoff
Book Image

Writing API Tests with Karate

By: Benjamin Bischoff

Overview of this book

Software in recent years is moving away from centralized systems and monoliths to smaller, scalable components that communicate with each other through APIs. Testing these communication interfaces is becoming increasingly important to ensure the security, performance, and extensibility of the software. A powerful tool to achieve safe and robust applications is Karate, an easy-to-use, and powerful software testing framework. In this book, you’ll work with different modules of karate to get tailored solutions for modern test challenges. You’ll be exploring interface testing, UI testing as well as performance testing. By the end of this book, you’ll be able to use the Karate framework in your software development lifecycle to make your APIs and applications robust and trustworthy.
Table of Contents (15 chapters)
1
Part 1:Karate Basics
7
Part 2:Advanced Karate Functionalities

Redirecting HTTP calls

If you remember, in Chapter 6, More Advanced Karate Features, we had an example of authenticating an API using an authentication token. Now, imagine—for example—having a real login to a website performed in Karate UI and then reusing the authentication token in Karate API requests. In another example, you could get the order number for a certain product from a store API using Karate API requests and then automatically enter it into the search mask on a website to further test the UI with this exact product.

Here, it becomes clear how powerful the combination of these two Karate test modules is. However, the whole situation becomes even more powerful when we use the mocking capabilities that we already learned about in Chapter 7, Customizing and Optimizing Karate Tests!

Chrome only

This mocking capability is only available in Chrome when using the Karate Chrome driver (the ChromeDriver driver will not work since it uses the WebDriver protocol...