01 Basic Script - biswajitsundara/Karate GitHub Wiki

BasicResponse.feature

Feature: User details
  
  Background:
      * url 'https://reqres.in'

  Scenario: Get call test
    Given path '/api/users/2'
    When method GET
    Then status=200
    Then print response

BasicTestRunner.java

import org.junit.runner.RunWith;

import com.intuit.karate.junit4.Karate;

@RunWith(Karate.class)
public class BasicTestRunner {

}

Explanation

  • Here * url means the keyword can be anything. We can write Given url also
  • But usually for specifying url, declaring variables, reading file steps we use *
  • The path keyword will append the string with url string and the result will be used as API URI.
  • Which is in this case https://reqres.in//api/users/2
  • The method keyword helps to fetch or push data. GET means it will fetch the data
  • The status keyword fetches the status of the API call.
  • The print keyword prints & the response keyword fetches the response of the call in JSON
⚠️ **GitHub.com Fallback** ⚠️