Overview
Karate Tools is a toolkit to facilitate a karate module’s:
βοΈ initialization and configuration through a maven archetype
ποΈ automated generation of test scenarios, test data and external services mocks from Open API
π οΈ usual operations such as authentication, database interaction, messaging (Kafka & JMS), …
β© execution in different enviroments of karate tests for a REST artifact.
Features
Using an archetype (karatetools-archetype), it will generate a karate project from scratch with the necessary configurations and utilities for the generation and execution of karate tests.
-
Configuration files (karate, auth, jdbc, kafka, …)
-
JavaScript and Karate utilities which include:
-
the management of files and payloads
-
Authentication (basic, jwt, …) allowing to change from one to another via the test configuration.
-
Initialization and management of Karate mock servers for external services
-
-
Java dependencies to the karatetools-starter which include:
-
open-api-generator Java Command Line Interface for the automatic generation of tests in Gherkin, with their related data sets and schemas for response validation as well as data to mock external services from Open Api definitions.
-
Java Clients to interact with Relational Databases (JDBC), Non-relational Database (Mongo), Event Messaging (Kafka Consumer and Producer) and JMS Messaging (JMS Send and JMS Consume)
-
Java KarateCache to be able to share variables across tests.
-
Setup and Usage
To setup up a karate project for testing of a REST artifact, you should follow the next steps:
-
Ensure the Prerequisites are fullfilled
-
Execute the Archetype to setup the initial karate project
-
Follow the Configuration steps
-
Generate tests, data sets and mocks
-
From Open API definitions with the Open Api Generator
-
-
Integrate Karate Clients in the tests for test data preparation and test validation
-
Follow the Execution instructions about execution, reporting, start a local application and other utilities usage (KarateCache, …).
Examples and Training
-
The karate tools repository includes working examples for the different karate tools features.
-
e2e/karate/src/test/resources
e2e/karate/src/test/resources βββ com βββ inditextech βββ karate βββ auth βββ base βββ clients β βββ db β β βββ JDBCClient-MariaDB.feature β β βββ JDBCClient-PostgreSQL.feature β βββ jms β β βββ JMSClient-ActiveMQ.feature β βββ kafka β β βββ KafkaClients.feature β βββ mongodb β βββ MongoDBClient.feature βββ karatetools-openapi-test βββ xxx-api-rest-stable βββ functional β βββ e2e β βββ e2e.feature β βββ test-data βββ smoke βββ BasicApi βββ createItems β βββ createItems.feature β βββ test-data βββ listItems β βββ listItems.feature β βββ test-data βββ showItemById βββ showItemById.feature βββ test-data
Modules
Feature | Description |
---|---|
βοΈ Karate Tools Archetype |
Archetype to initialize a Karate maven project from scratch with all its dependencies |
Automatic generation of tests in Gherkin, with their related data sets and schemas for response validation as well as data to mock external services from Open Api definitions. |
|
βοΈ Karate Clients |
Clients to interact with Relational Databases (JDBC), Non-relational Database (Mongo), Event Messaging (Kafka Consumer and Producer) and JMS Messaging (JMS Send and JMS Consume). |