TestingDocs.com
Software Testing website
  • Automation
    • Selenium
    • JBehave Framework
  • Tutorials
    • MySQL Tutorials
    • Testlink
    • Maven
    • Git
  • IDEs
    • IntelliJ IDEA
    • Eclipse
  • Flowcharts
    • Flowgorithm
    • Raptor
  • About

Karate

Create Karate API Test Script( Feature File )

Overview

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:

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, choose New >> File. Give a name to the feature file. Note that the feature file should have .feature file extension.

 

New Feature File Karate

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

https://www.testingdocs.com/create-issue-using-mantis-rest-api/

MantisBT Rest API Guide

https://www.testingdocs.com/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

 

Run Cucumber Feature

 

This option would run the automation script and reports the result in the console.

 

Karate API Testing Feature

 

That’s it.

—

Karate Automation Tutorials

Karate tool tutorials on this website can be found at:

https://www.testingdocs.com/karate-automation-tool-tutorials/

More information on the tool:

https://github.com/intuit/karate

Related Posts

Multiple Threads Karate Automation

Karate /

Parallel Test Execution using Karate DSL

Get API Request

Karate /

Test GET API Request with Karate DSL

Karate /

CRUD Operations API Test Automation with Karate

Data Driven Testing Karate

Karate /

Data Driven Testing using Karate Automation Tool

Karate Automation Project

Karate /

Getting Started with Karate DSL

‹ CRUD Operations API Test Automation with Karate› Test GET API Request with Karate DSL

Recent Posts

  • MS Access Data Types
  • Install RAPTOR Avalonia on CentOS
  • Download RAPTOR Avalonia Edition on Windows
  • npm doctor command
  • Build & Run CLion Project
  • Create New CLion C Project on Windows
  • Configure CLion Toolchains on Windows
  • Launch CLion IDE on Windows
  • Activate CLion IDE
  • CLion IDE for C/C++ Development

Back to Top

Links

  • Contact
  • Privacy Policy
  • Cookie Policy

www.TestingDocs.com

Go to mobile version