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.

Architecture

The high-level architecture of Karate Tools is shown in the following diagram:

architecture

Setup and Usage

To setup up a karate project for testing of a REST artifact, you should follow the next steps:

  1. Ensure the Prerequisites are fullfilled

  2. Execute the Archetype to setup the initial karate project

  3. Follow the Configuration steps

  4. Generate tests, data sets and mocks

    1. From Open API definitions with the Open Api Generator

  5. Integrate Karate Clients in the tests for test data preparation and test validation

  6. 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

βš™οΈ Karate Tools Open Api Generator

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).