karatetools-oss
Overview
This library is a general purpose library that can be used by any Karate project.
The Karate Tools Open Source Repository is organized as follows:
-
code
- Karate Tools Open Source codebase with the corresponding unit and integration tests-
π©βπ» karatetools-oss-code
-
-
e2e/karate
- Karate Tools Open Source karate tests -
docs
- Karate Tools Open Source documentation based on asciidoc and antora-
π karatetools-oss-docs
-
βββ code (1)
β βββ archetype (2)
β β βββ src
β β βββ test
β β βββ java
β β βββ resources
β ...
β βββ starter (2)
βββ docs (3)
β βββ build (4)
β βββ node_modules (4)
β βββ src
β β βββ modules (5)
β β βββ HOME
β β β βββ images
β β β βββ pages
β β ...
β β βββ release
β βββ supplemental-ui (6)
βββ e2e
βββ karate (7)
βββ src
βββ test
βββ java
βββ resources
1 | codebase root directory |
2 | codebase maven modules |
3 | documentation root directory |
4 | documentation build and node directories |
5 | documentation antora asciidoc modules |
6 | documentation antora UI assets (page templates, CSS, JavaScript, images, etc.) |
7 | karate-test maven module root directory |
The main code
modules are:
-
π©βπ»
karatetools-oss-archetype
: archetype to generate a karate project from scratch with the necessary configurations and utilities for the execution of tests. -
π©βπ»
karatetools-oss-clients
: clients to interact with relational databases via JDBC (MariaDB and PostgreSQL), MongoDB, Kafka and JMS (Active MQ) -
π©βπ»
karatetools-oss-generators
: generators of tests from Open API -
π©βπ»
karatetools-oss-runner
: karate runner and all related utilities (authentication, JWT tokens, karate base configuration, karate utils, karate mocks, karate cache, karate results and reports, …) -
π©βπ»
karatetools-oss-starter
: starter module to include the generators, clients and runner in a Karate project.
It includes test open api modules:
-
π©βπ»
karatetools-oss-openapi-test
: Open API test specifications for the karate tools tests with two sub-modules:-
π©βπ»
karatetools-oss-xxx-api-rest-stable
: api to test the test generation tools -
π©βπ»
karatetools-oss-xxx-external-api-rest-stable
: api to test the mock generation tools
-
It includes a spring boot module:
-
π©βπ»
karatetools-oss-boot
: spring boot application with a simple rest api implementing the Open API test specification and docker containers to be used as target for the karate tools tests (runner, rest, auth, jdbc, mongodb, kafka, jms, …)
The karate test module is defined in the e2e/karate
folder:
-
π§ͺ
karatetools-oss-karate-test
: karate module to test the karate tools.-
This module has been generated using the βοΈ Karate Tools - Archetype
-
Includes auto-generated tests and mocks for sample api (
karatetools-oss-openapi-test
) -
uses the
karatetools-oss-starter
to test the karate clients and the sample application (karatetools-oss-boot
) and containers.
-
The documentation is defined in the docs
folder:
-
π
karatetools-oss-docs
: documentation of the karate tools based on asciidoc and antora.

karatetools-oss-code
The following sections will describe the code structure, to be able to find easily the location of the code to be added or modified.
-
π©βπ» karatetools-oss-archetype
-
π©βπ» karatetools-oss-clients
-
π©βπ» karatetools-oss-generators
-
π©βπ» karatetools-oss-runner
-
π©βπ» karatetools-oss-starter
-
π©βπ» karatetools-oss-boot
-
π©βπ» karatetools-oss-openapi-test
The tests to be executed for the code
modules are:
-
Unit & Mutation Tests:
-
Unit tests are used to test the classes and methods of the
code
modules. -
Mutation tests are used to verify that the unit tests are effective.
-
-
Integration tests:
-
Integration tests are used to test the
code
modules together with external dependencies. -
These tests are supported by a set of
docker containers
located incode/src/test/resources/compose
-
Unit, mutation and integration tests are required as status checks in the CI/CD pipeline pull request approval process. The level of coverage for each type of test must reach at least the defined threshold. |
Karate tests are defined in the e2e/karate folder and are executed in the karatetools-oss-karate-test module.
|
test | command | report | verification |
---|---|---|---|
unit |
|
|
all tests pass and the code coverage generated by unit tests is at least 90% |
mutation |
|
|
all tests pass and the mutation coverage is at least 90% |
integration |
|
|
all tests pass and the code coverage generated by integration tests is at least 80% |
test | command | report | verification |
---|---|---|---|
unit |
|
workflow execution reports |
automatically on workflow execution |
mutation |
|
workflow execution reports |
automatically on workflow execution |
integration |
|
workflow execution reports |
automatically on workflow execution |
compatibility |
|
workflow execution reports |
automatically on workflow execution |
karatetools-oss-archetype
What is Archetype? In short, Archetype is a Maven project templating toolkit. An archetype is defined as an original pattern or model from which all other things of the same kind are made.
The karatetools-oss-archetype
module povides the templates and scripts to generate karate-test modules.
This module has the following structure:

It includes the following files:
code/archetype/
βββ pom.xml
βββ src
Β Β βββ main
Β Β βΒ Β βββ resources
Β Β βΒ Β βββ META-INF
Β Β βΒ Β βΒ Β βββ archetype-post-generate.groovy (1)
Β Β βΒ Β βΒ Β βββ maven
Β Β βΒ Β βΒ Β βββ archetype-metadata.xml (2)
Β Β βΒ Β βββ archetype-resources (3)
Β Β βΒ Β βββ .gitignore (4)
Β Β βΒ Β βββ .tool-versions (5)
Β Β βΒ Β βββ pom.xml (6)
Β Β βΒ Β βββ src
Β Β βΒ Β βββ test
Β Β βΒ Β βββ java
Β Β βΒ Β βΒ Β βββ KarateRunnerTest.java (7)
Β Β βΒ Β βββ resources
Β Β βΒ Β βββ config (8)
Β Β βΒ Β βΒ Β βββ db
Β Β βΒ Β βΒ Β βΒ Β βββ mariadb-config-local.yml
Β Β βΒ Β βΒ Β βΒ Β βββ mongodb-config-local.yml
Β Β βΒ Β βΒ Β βΒ Β βββ postgresql-config-local.yml
Β Β βΒ Β βΒ Β βββ jms
Β Β βΒ Β βΒ Β βΒ Β βββ activemq-config-local.yml
Β Β βΒ Β βΒ Β βββ kafka
Β Β βΒ Β βΒ Β βββ kafka-config-local.yml
Β Β βΒ Β βββ config-local.yml (9)
Β Β βΒ Β βββ config.yml (9)
Β Β βΒ Β βββ jwt
Β Β βΒ Β βΒ Β βββ default-jwt.yml (10)
Β Β βΒ Β βββ karate-config.js (11)
Β Β βΒ Β βββ logback-test.xml (12)
Β Β βΒ Β βββ mocks
Β Β βΒ Β βββ templates
Β Β βΒ Β βββ standalone (13)
Β Β βΒ Β βββ .gitkeep
Β Β βββ test
Β Β βββ resources
Β Β βββ projects (14)
Β Β βββ all (15)
Β Β βΒ Β βββ archetype.properties (16)
Β Β βΒ Β βββ goal.txt (17)
Β Β βΒ Β βββ reference (18)
β βββ .gitignore
β βββ .tool-versions
β βββ pom.xml
β βββ ...
Β Β βββ default (15)
Β Β βΒ Β βββ archetype.properties (16)
Β Β βΒ Β βββ goal.txt (17)
Β Β βΒ Β βββ reference (18)
β βββ .gitignore
β βββ .tool-versions
β βββ pom.xml
β βββ ...
Β Β ...
1 | post-processing script to choose the files to include based on the archetype properties which are prompted to the user. |
2 | archetype descriptor, metadata defining the archetype properties, files and directories, and the post-processing script. |
3 | the prototype files that are copied by the archetype plugin to the target module |
4 | prototype: Git ignore file |
5 | prototype: Tools version manager file |
6 | prototype: Karate pom file |
7 | prototype: Java Test Runner |
8 | prototype: karate clients configuration files templates |
9 | prototype: Configuration Files (general and environment specific) |
10 | prototype: Karate Authentication Default JWT |
11 | prototype: Karate-config file |
12 | prototype: logback configuration file |
13 | prototype: karate mocks folder to define standalone mock templates |
14 | test projects to test the archetype generation with different configurations |
15 | test: project folder |
16 | test: archetype properties (groupId, artifactId, version, …) |
17 | test: maven goal to be executed for the project test, for example: clean validate |
18 | test: expected output files |
Any changes made in the prototype files and/or processing scripts must be reflected in the corresponding output project tests. |
karatetools-oss-clients
The karatetools-oss-clients
module includes the following core and support packages.
The core packages are:
-
π¦
dev.inditex.karate.db
: JDBC client to interact with relational databases. The included drivers are:-
π’οΈ MariaDB
-
π’οΈ PostgreSQL
-
-
π¦
dev.inditex.karate.mongodb
: MongoDB client to interact with MongoDB. -
π¦
dev.inditex.karate.kafka
: Kafka clients to interact with Kafka. -
π¦
dev.inditex.karate.jms
: JMS client to interact with JMS. The included clients are:-
βοΈ Active MQ Artemis
-
The support packages are:
-
π¦
dev.inditex.karate.logging
: logging utilities to log the clients methods. -
π¦
dev.inditex.karate.parser
: parser utilities to parse the clients configuration files and inject system properties.

karatetools-oss-generators
The karatetools-oss-generators
module includes the following packages:
-
π¦
dev.inditex.karate.openapi
: Open API generator to create test scenarios, test data and external services mocks from Open API specifications. -
π¦
dev.inditex.karate.console
: request user input from the console (which API specification file to use, which operations to generate, etc).

karatetools-oss-runner
The karatetools-oss-runner
module includes the following packages:
-
π¦
dev.inditex.karate.jwt
: JWT generator to create JWT tokens for authentication and authorization purposes in Karate tests. -
π¦
dev.inditex.karate.results
: results generators to aggregate the cucumber results of the test scenarios, to create statistics on the karate operations usage and to copy the junit reports to the surefire folder. -
π¦
dev.inditex.karate.test
: karate runner to run the karate tests and karate cache to share variables across tests.
It also includes the following karate resources:
-
π
karate-base.js
: karate base configuration -
π
karate-utils.js
: karate tools utility js functions -
karate-auth
(basic
,jwt
):-
π
karate-auth.feature
: common features to connect to authentication services. -
π
karate-auth.js
: karate auth functions to orquestrate the authentication and authorization process.
-
-
mocks
:-
π
mock-templates.feature
: common feature to launch the mocks. -
π
mock-templates-functions.js
: karate mocks functions to find, load, … the mock templates. -
π
mock-templates-inline.feature
: feature to launch the mocks in inline mode. -
π
mock-templates-standalone.feature
: feature to launch the mocks in standalone mode.
-

karatetools-oss-starter
The karatetools-oss-starter
module is a packaging
module that includes the dependencies needed for a karate project to be able to use the karate tools, karatetools-oss-clients
, karatetools-oss-generators
and karatetools-oss-runner
modules as well as any other necessary dependencies.
karatetools-oss-boot
The karatetools-oss-boot
module includes the following packages:
-
π¦
dev.inditex.karate
: Spring Boot Application -
π¦
dev.inditex.karate.config
: Spring Boot Application configuration -
π¦
dev.inditex.karate.controller
: Spring Boot Application controllers implementing the Open API test specification and docker containers to be used as target for the karate tools tests (runner, rest, auth, jdbc, mongodb, kafka, jms, …). The controller package includes the following classes:-
BasicApiController.java
: Controller implementing the Open API test specification. -
DockerHealthController.java
: Controller to check the status of the docker containers.
-
The docker containers are defined in the docker-compose.yml
file and are started automatically when the application is started.

The karatetools-oss-boot
module includes all the integration tests for the karate tools.
Any changes made in the Karate Tools codebase must be reflected in the corresponding integration tests in this module, both as java tests and as karate scenarios (when applicable). |

karatetools-oss-openapi-test
The karatetools-oss-openapi-test
module contains two submodules that represent the two APIs to be tested:
code/openapi-test/
βββ pom.xml
βββ xxx-api-rest-stable
β βββ pom.xml
β βββ src
β βββ main
β βββ resources
β βββ components.yml
β βββ openapi-rest.yml
βββ xxx-external-api-rest-stable
βββ pom.xml
βββ src
βββ main
βββ resources
βββ components.yml
βββ openapi-rest.yml
Both APIs are identical, but they are used to demonstrate the testing of two different APIs (self and external APIs). |
The xxx-api-rest-stable
and xxx-external-api-rest-stable
api structure is as follows:


karatetools-oss-karate-test
This module karatetools-oss-karate-test
is a karate module to test the karate tools.
-
This module has been generated using the βοΈ Karate Tools - Archetype
-
Includes auto-generated tests and mocks for sample api (
karatetools-oss-openapi-test
) -
uses the
karatetools-oss-starter
to test the karate clients and the sample application (karatetools-oss-boot
) and containers.
Any changes made in the Karate Tools codebase must be reflected in the corresponding karate tests in this module. |
The structure of the module is as follows:

-
src/test/java: Java Code
e2e/karate/ βββ .gitignore βββ pom.xml βββ src βββ test βββ java β βββ com β βββ inditextech β βββ karate β βββ karatetools β βββ jms β β βββ JMSKarateObject.java (1) β βββ test β βββ KarateRunnerTest.java (2)
1 JMS Object for testing purposes 2 Java Test Runner -
src/test/resources: Base and Config files
e2e/karate/ βββ .gitignore βββ pom.xml βββ src βββ test βββ resources βββ config (1) β βββ db β β βββ mariadb-config-local.yml β β βββ mongodb-config-local.yml β β βββ postgresql-config-local.yml β βββ jms β β βββ activemq-config-local.yml β βββ kafka β βββ avro β β βββ karate.avsc β βββ kafka-config-local.yml βββ config-local.yml (2) βββ config.yml (2) βββ jwt (3) β βββ default-jwt.yml β βββ invalid-jwt.yml βββ karate-config.js (4) βββ logback-test-debug.xml (5) βββ logback-test.xml (5) βββ mocks (6) βββ templates βββ standalone βββ .gitkeep
1 Karate clients config files (db, jms, kafka) 2 Configuration Files (general and environment specific) 3 Karate Authentication JWT Files (default and test specific) 4 Karate-config files 5 logback configuration files 6 karate mocks folder -
src/test/resources/dev/inditex/karate: Tests related to Karate Tools features
e2e/karate/ βββ .gitignore βββ pom.xml βββ src βββ test βββ resources βββ com β βββ inditextech β βββ karate β βββ auth (1) β β βββ KarateAuthBackgroundScenario.feature β β βββ KarateAuthBasic.feature β β βββ KarateAuthJWT.feature β βββ base (2) β β βββ KarateBase.feature β βββ clients (3) β β βββ db (4) β β β βββ JDBCClient-MariaDB.feature β β β βββ JDBCClient-MariaDB.sql β β β βββ JDBCClient-PostgreSQL.feature β β β βββ JDBCClient-PostgreSQL.sql β β βββ jms (5) β β β βββ JMSClient-ActiveMQ.feature β β βββ kafka (6) β β β βββ KafkaClients.feature β β βββ mongodb (7) β β βββ MongoDBClient.feature
1 Authentication tests 2 Karate Base tests 3 Karate Clients tests 4 Karate Clients tests: db 5 Karate Clients tests: jms 6 Karate Clients tests: kafka 7 Karate Clients tests: mongodb -
src/test/resources/apis/dev/inditex/karate/karatetools-openapi-test/xxx-api-rest-stable: Root folder for the operation(s) feature files and validation schemas for the test api xxx-api-rest-stable
e2e/karate/ βββ .gitignore βββ pom.xml βββ src βββ test βββ resources βββ apis β βββ com β βββ inditextech β βββ karate β βββ karatetools-openapi-test β βββ xxx-api-rest-stable (1) β βββ BasicApi (2) β βββ createItems (3) β β βββ createItems.feature (4) β β βββ schema (5) β β βββ createItems_201.schema.yml β β βββ createItems_400.schema.yml β β βββ createItems_401.schema.yml β β βββ createItems_default.schema.yml β βββ listItems (3) β β βββ listItems.feature (4) β β βββ schema (5) β β βββ Items_200.schema.yml β β βββ listItems_200.schema.yml β β βββ listItems_400.schema.yml β β βββ listItems_401.schema.yml β β βββ listItems_default.schema.yml β βββ showItemById (3) β βββ schema (5) β β βββ showItemById_200.schema.yml β β βββ showItemById_401.schema.yml β β βββ showItemById_404.schema.yml β β βββ showItemById_default.schema.yml β βββ showItemById.feature (4)
1 root folder for the operations 2 api tag folder 3 operation folder 4 operation feature file 5 operation validation schemas -
src/test/resources/dev/inditex/karate/karatetools-openapi-test/xxx-api-rest-stable: REST Api tests
e2e/karate/ βββ .gitignore βββ pom.xml βββ src βββ test βββ resources βββ com β βββ inditextech β βββ karate β βββ karatetools-openapi-test β βββ xxx-api-rest-stable (1) β βββ functional (2) β β βββ e2e (3) β β βββ e2e.feature (4) β β βββ test-data (5) β β βββ createItems_201.yml β β βββ createItems_400.yml β β βββ createItems_401.yml β β βββ listItems_200.yml β β βββ listItems_400.yml β β βββ listItems_401.yml β β βββ showItemById_200.yml β β βββ showItemById_401.yml β β βββ showItemById_404.yml β βββ smoke (6) β βββ BasicApi (7) β βββ createItems (8) β β βββ createItems.feature (4) β β βββ test-data (5) β β βββ createItems_201.yml β β βββ createItems_400.yml β β βββ createItems_401.yml β βββ listItems (8) β β βββ listItems.feature (4) β β βββ test-data (5) β β βββ listItems_200.yml β β βββ listItems_400.yml β β βββ listItems_401.yml β βββ showItemById (8) β βββ showItemById.feature (4) β βββ test-data (5) β βββ showItemById_200.yml β βββ showItemById_401.yml β βββ showItemById_404.yml
1 root folder for the rest api test 2 root folder for the functional rest api tests 3 specific functional test folder 4 feature file 5 test data files 6 root folder for the smoke rest api tests 7 api tag folder 8 smoke tests operation folder
The tests to be executed are:
-
Karate Tests:
-
Karate tests are used to test the karate tools in the context of a Karate project.
-
These tests are executed against the test application Rest Api and the
docker containers
provided by thekaratetools-oss-boot
module.
-
Karate tests are required as status checks in the CI/CD pipeline pull request approval process. The level of coverage for the karate tests must reach at least the defined threshold. |
test | command | report | verification |
---|---|---|---|
Build app |
|
NA |
no errors |
Start app |
|
NA |
no errors |
karate |
|
|
all tests pass |
test | command | report | verification |
---|---|---|---|
karate |
|
workflow execution reports |
automatically on workflow execution |
step | commands | expected output |
---|---|---|
Build app |
|
build without errors |
Download JaCoCo agent and client |
|
JaCoCo agent and client downloaded |
Start app with JaCoCo agent |
|
App started with JaCoCo agent |
Wait for app to start |
|
Status code 200 |
Check docker containers are up |
|
All docker containers are up in |
Execute Karate tests |
|
all tests pass |
Check karate report |
|
all tests pass |
Stop app |
|
App stopped |
Generate JaCoCo report |
|
JaCoCo report generated |
Check JaCoCo report |
|
code coverage generated by karate tests is at least 80% |
karatetools-oss-docs
The documentation module karatetools-oss-docs
follows standard structure for Antora documentation:
docs
βββ antora-playbook-local.yml (1)
βββ antora-playbook.yml (1)
βββ build (2)
βββ node_modules (3)
βββ package-lock.json (4)
βββ package.json (4)
βββ src (5)
βΒ Β βββ antora.yml (6)
βΒ Β βββ modules (7)
βΒ Β βββ HOME
βΒ Β βββ archetype
βΒ Β βββ clients
βΒ Β βββ configuration
βΒ Β βββ contributing
βΒ Β βββ execution
βΒ Β βββ open-api-generator
βΒ Β βββ overview
βΒ Β βββ prerequisites
βΒ Β βββ puml
βΒ Β βββ release
βββ supplemental-ui (8)
βΒ Β βββ css
βΒ Β βββ img
βΒ Β βββ js
βΒ Β βββ partials
βββ ui-bundle.zip (9)
1 | Antora playbooks |
2 | Build folder where the output documentation is generated |
3 | Node modules folder |
4 | Node package configuration file |
5 | Content source root folder |
6 | antora.yml (reserved file name): Antora component version descriptor file. This file indicates to Antora that the contents of a directory named modules should be collected and processed. |
7 | modules (reserved directory name): Antora required directory located at the same hierarchical level as the antora.yml file. The modules directory must contain, at a minimum, either a ROOT module directory or a named module directory. |
8 | Supplemental UI to customize the UI bundle |
9 | Antora Default UI bundle |
To locally build the documentation, you can use the following command:
# Change to the docs directory
cd docs
# Install the required dependencies
npm install
# Start the local kroki server
docker run -p8000:8000 -d yuzutech/kroki
# Build the documentation and start the local server to serve it
npm start
This command will start a local server that will serve the documentation at http://localhost:8080
. If port 8080
is already in use, the server will use the next available port, such as 8081
or 8082
.

