Writing API Tests with Karate : Enhance Your API Testing for Improved Security and Performance / Benjamin Bischoff ; foreword by Peter Thomas.

Author
Bischoff, Benjamin [Browse]
Format
Book
Language
English
Εdition
First edition.
Published/​Created
  • Birmingham, England : Packt Publishing Ltd., [2023]
  • ©2023
Description
1 online resource (326 pages) : illustrations

Details

Subject(s)
Writer of foreword
Summary note
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.
Notes
Includes index.
Source of description
Description based on print version record.
Contents
  • Cover
  • Title Page
  • Copyright and Credits
  • Foreword
  • Contributors
  • About the reviewer
  • Table of Contents
  • Preface
  • Part 1:Karate Basics
  • Chapter 1: Introducing Karate's Core Concepts
  • Technical requirements
  • What makes Karate stand out?
  • Discovering Karate's strong points
  • Core features
  • BDD versus Karate
  • What is BDD?
  • Glue code
  • The Karate way
  • Supported data types in Karate
  • JSON
  • GraphQL
  • XML
  • YAML
  • CSV
  • Other text-based formats
  • Binary formats
  • The JavaScript engine
  • Java interoperability
  • Summary
  • Chapter 2: Setting up Your Karate Project
  • Installing Java
  • Setting the JAVA_HOME environment variable
  • Getting to know Karate standalone
  • Preparing the IDE
  • Setting up Visual Studio Code
  • Setting up IntelliJ IDEA
  • Importing the example project
  • Setting up Karate projects with Maven
  • What is Maven?
  • Installing Maven
  • Adding Maven to the PATH variable
  • Setting up a Karate project with the Maven archetype
  • The roles of the different Karate project files
  • Chapter 3: Writing Basic Karate Tests
  • Exploring the API under test
  • The JSONPlaceholder API
  • Creating a new Karate project
  • Adding a new feature file
  • Configuring test runs
  • Adding a scenario
  • Calling endpoints and setting parameters
  • Setting a URL
  • Specifying the HTTP method
  • Separating the base URL from the path
  • Setting query parameters
  • Matching status codes and responses
  • Matching the status code and type
  • Making the test fail
  • Using assertions and matchers on the response
  • Exploring the response variable
  • Handling nested JSON elements
  • Asserting the number of elements with the length property
  • Using matchers
  • Making requests with payloads
  • Using variables and data tables
  • Using variables.
  • Using data tables
  • Using a set
  • Chapter 4: Running Karate Tests
  • Running and debugging Karate tests through the IDE
  • Running via CodeLens and the Karate CLI
  • Debugging via CodeLens and Karate standalone
  • Using the debug server
  • Running tests with Maven
  • Understanding Karate runners
  • Running tests against different environments
  • Using a custom property in a feature file
  • Using Karate's environment property
  • Setting up karate-config.js
  • Running specific tests
  • Running specific runner class methods
  • Running specific scenarios
  • Filtering tests by tags
  • Chapter 5: Reporting and Logging
  • Configuring log options
  • Understanding log levels
  • Changing the log level
  • Suppressing print
  • Using Karate's built-in reports
  • The different report pages
  • Preserving old reports
  • Deciding what to report
  • Configuring third-party report libraries
  • Setting the appropriate Karate options
  • Using Cluecumber as a Maven plugin
  • Using Cluecumber from a Karate runner
  • Generating a Surefire report
  • Surefire XML
  • Using JUnit reports
  • Part 2:Advanced Karate Functionalities
  • Chapter 6: More Advanced Karate Features
  • Working with headers and cookies
  • More about headers
  • Setting headers
  • More about cookies
  • Using different configuration and run options
  • Using the karate object for configuration and execution
  • Request retries
  • Using advanced tags
  • Defining and using expressions with def
  • Defining inline methods
  • Using embedded expressions with JSON
  • Using embedded expressions with XML
  • Working with external files
  • Understanding JSONPath and XPath
  • Testing GraphQL
  • Understanding GraphQL requests
  • Exploring the mock API
  • Using GraphQL in Karate.
  • Collecting data into a new array
  • Chapter 7: Customizing and Optimizing Karate Tests
  • Using Karate hooks
  • Implementing a new hook class
  • Overriding handler methods
  • Registering a hook class in the runner
  • Running a test using the hook class
  • Defining hooks inside feature files
  • Defining and calling Java functions
  • Understanding the basics
  • Working with databases
  • Using Karate as a mock server
  • Authoring a mock scenario
  • Firing up the mock server from within a test
  • Using a standalone mock server
  • Making your tests more concise
  • Reducing code by calling other feature files
  • Data-driven tests with scenario outline
  • Avoiding code duplication with background scenarios
  • Chapter 8: Karate in Docker and CI/CD pipelines
  • Triggering Karate tests from shell scripts
  • Creating a batch script for Windows
  • Creating a Bash script
  • Running Karate tests in a Docker container
  • Understanding Docker
  • Installing Docker
  • Starting and verifying a Docker installation
  • Downloading a Docker image
  • Running a Maven command in a Maven Docker container
  • Running Karate tests inside a Maven Docker container
  • Running our shell script inside Docker
  • Customizing our tests
  • Passing database credentials as system properties
  • Using the system properties in the database connection class
  • Passing parameters from Docker
  • Environment variables
  • Integrating Karate tests into GitHub workflows
  • Understanding GitHub workflows
  • Managing secrets
  • Adding a GitHub workflow to a repository
  • Setting up the Docker-based GitHub workflow
  • Using Karate in a GitHub workflow without Docker
  • Chapter 9: Karate UI for Browser Testing
  • What Karate UI is for
  • Related testing capabilities.
  • Writing a basic Chrome scenario
  • Opening a website in Chrome
  • Finding and interacting with elements
  • Understanding locators
  • Knowing the different kinds of locators
  • Determining element locators
  • Interacting with elements
  • Using interactions in a test scenario
  • Making web element assertions
  • Making web element list assertions
  • Debugging UI tests
  • Taking screenshots
  • Highlighting elements
  • Exporting PDFs
  • Using the debugger
  • Using karate.stop to pause execution
  • Redirecting HTTP calls
  • Investigating API requests
  • Adding a mock response
  • Configuring the mock
  • Using the mock in a test
  • Chapter 10: Performance Testing with Karate Gatling
  • Creating the test scenario
  • What is Gatling?
  • Setting up Karate Gatling
  • Setting up Scala in VS Code
  • Creating Maven profiles
  • Running Karate tests as performance tests
  • Creating a simulation
  • Running the simulation
  • Using tags
  • Testing different simulations
  • Gatling assertions
  • Checking out Gatling reports
  • Index
  • Other Books You May Enjoy.
ISBN
  • 9781837631056
  • 1837631050
OCLC
1379845335
Statement on responsible collection description
Princeton University Library aims to describe library materials in a manner that is respectful to the individuals and communities who create, use, and are represented in the collections we manage. Read more...
Other views
Staff view

Supplementary Information