Create Karate API Test Script( Feature File )
In this tutorial, we will learn steps involved to create Karate API test script. Karate DSL is based on BDD syntax. A Karate Test script is a feature file. The feature file should have an .feature file extension.
Install Cucumber Plugin
On Eclipse IDE, we can install Cucumber Plugin to run .feature files. Steps to install Cucumber plugin in Eclipse IDE can be found at:
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, choose New >> File. Give a name to the feature file. Note that the feature file should have .feature file extension.
Simple BDD Feature Format
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 the Automation Test
Right click on the Automation feature file and choose Run As >> Cucumber Feature
This option would run the automation script and reports the result in the console.
Karate Automation Tutorials
Karate tool tutorials on this website can be found at:
More information on the tool: