Create Karate API Test Script
Create Karate API Test Script
In this tutorial, you will learn how to create a Karate API test script. Karate DSL is based on BDD syntax. A Karate Test script is a feature file, and it should have a .feature file extension.
Install Cucumber Plugin
On Eclipse IDE, we can install Cucumber Plugin to run .feature files. Steps to install the Cucumber plugin in Eclipse IDE can be found at:
https://www.testingdocs.com/questions/how-to-install-cucumber-eclipse-plugin/
Karate API Test Script
Add an automation story in BDD syntax. There is no need to code the step definitions. Karate tool provides you with the step definitions. We just need to follow the Karate DSL syntax.
To create a feature file, right-click on the Project Explorer and choose New >> File.
Give the feature file a name. The file should have the .feature extension.
Simple BDD Feature Format
@tag
Scenario: Sample Title of the Scenario
Given I want to write a step with some precondition
And some other precondition
When I complete action
Then I validate the action outcome
MantisBT Rest API
MantisBT is an open source bug tracking and issue tracking tool. The tool exposes Rest API to interact with the MantisBT instance without the web interface.
Create Issue using REST API
MantisBT Rest API Guide
Sample Feature to Test GET API call
Sample Feature file shown below:
#Sample Feature - www.TestingDocs.com @tag Feature: MantisBT REST API Test I want to test MantisBT Rest API @getMantisIssue Scenario: GET MANTIS ISSUE Given url 'http://localhost/mantis/api/rest/issues/5' And header Authorization = 'DoZSsCCiTFEx8jIm67F4mM7RWh_NLEVd' When method GET Then status 200
Run Automation Test
Right-click on the Automation feature file and choose Run As >> Cucumber Feature
This option would run the automation script and report the result in the console.
That’s it.
—
Karate Automation Tutorials
Karate tool tutorials on this website can be found at: