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

    Karate

    Test GET API Request with Karate DSL

    Overview

    In this tutorial, we will test GET API Request with Karate DSL. Get Request is the simple API call to test both in manual mode and in Automation Testing.

    Test GET API Request

    Get request is used to retrieve information of the server side resource. The Gherkin for the Get Mantis Issue API call is shown below:

    To specify the API end point:

    Given url ‘<Get_API_URL_Endpoint>’

    To add HTTP Header

    And header Authorization = ‘<API_Token>’

    To specify the HTTP GET method:

    When method GET

    To verify the API Response status:

    Then status 200

    response is the variable that is set with the Response body. This variable will be refreshed for every HTTP call with the latest Response body.

    response.projects[0].name is JsonPath expression that we will discuss later. We are asserting for the Project name in the response body to decide the API test status for Pass/Fail. The test would be marked as Pass if the HTTP Status code == 200 AND Response Body contains the given Project name in the API call.

    Feature Gherkin BDD Syntax

    ## Karate API Tool Demo
    #Karate Framework Tutorials - www.TestingDocs.com
    
    @Mantis
    Feature: Get Project REST API Request
     I want to test Get Project Mantis Bug Tracker API
    
    
     Scenario: GET Project Test
     Given url 'http://localhost/mantis/api/rest/projects/1'
     And header Authorization = 'DoZSsCCiTFEx8jIm67F4mM7RWh_NLEVd'
     When method GET
     Then status 200
     Then match response.projects[0].name == 'TestingDocsProject'

    Get API Request

    Common Failure cases are

    404 Not Found -> When the API endpoint is not deployed or not exposed. Invalid API URL.

    401 Un authorized -> Wrong API token or missing token

    —

    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

    New Feature File Karate

    Karate /

    Create Karate API Test Script( Feature File )

    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

    ‹ Create Karate API Test Script( Feature File )› Parallel Test Execution using Karate DSL

    Recent Posts

    • ChatGPT Plans Free and PlusChatGPT Subscription Plans
    • Stellar Converter for Database ToolStellar Converter for Database
    • Stellar MySQL Log AnalyzerStellar Log Analyzer for MySQL
    • Stellar Repair for MySQLStellar Repair for MySQL
    • ChatGPT IntroductionChatGPT Capabilities
    • How to secure your SQL Database: Tips and Tricks
    • ChatGPT4 Conversational AI FeaturesChatGPT4 Conversational AI Features
    • Trends in Software EngineeringShaping the Future of Development: Exploring Key Trends in Software Engineering
    • Java PerformanceImproving Java Performance with Multithreading
    • QDrant Vector DatabaseOpen-source Vector Databases
    • Difference between PHP and JavaScript?
    • Bing AI Browser Web ContentBing Conversation Styles
    • ChatGPT PreviewChatGPT Introduction
    • Open Source AI Frameworks TensorFlowOpen Source AI Frameworks
    • Artificial Intelligence Tools

    Back to Top

    Links

    • Contact
    • Privacy Policy
    • Cookie Policy

    www.TestingDocs.com