Skip to content

prit-misik/karate-for-api-automation-with-azure-pipeline

Repository files navigation

API testing using Karate

Approach

After reviewing the problems with the existing framework, we've decided to use a tool that gives us flexibility as well as speed to add new tests. So we've started the approach using Karate APIs.

About Karate

Karate is the only open-source tool to combine API test automation, mocks, performance-testing and even UI automation into a single, unified framework. The BDD syntax popularized by Cucumber is language-neutral, and easy for even non-programmers. It is not a pure BDDframework.Assertions and HTML reports are built-in, and you can run tests in parallel for speed.There's also a cross-platform stand-alone executable for teams not comfortable with Java. Users don't have to compile code. Just write tests in a simple, readable syntax - carefully designed for HTTP, JSON, GraphQL and XML. And you can mix API and UI test-automation within the same test script.

This repository contains the current project, which shows how we can utilize Karate for robust API test cases, in a fast speed. It contains API tests, as well as performance tests, using the same set of feature files.

About the current framework :

  1. The test is written under "src/test/java//features"

  2. The file karate-config.js contains configurable envs which becomes global once the execution starts.

  3. The feature files under "src/test/java/features//" shows how different feature files can be re-used for testing, also demonstrate how to separate out test data from test cases.

  4. Every feature folder contains a resources folder where test data or other files are placed, for example, .json files used as a payload for test cases are placed here.

  5. There are two types of result files generated under target folder, out of which target\cucumber-html-reports are clearly better for reporting purpose. Also after the run a zipped result file is sent a s an email to "abc@gmail.com"

  6. Different tags are used to make tests moduler , current ly available tags are: -all -bbc -profile

  7. To run a set of test cases from the command line : ./gradlew clean test -Denv=dev-uk -Doptions="--tags @"

  8. Or the features can be run from any IDE , by right clicking and clicking run option.

  9. We are using the following Azure pipeline to trigger the tests

  10. Karate official documentation can be found here : https://github.com/karatelabs/karate

About

This projects demonstrates different aspects of the Karate tool, and how it can be used for API automation

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published