1. Install Karate

    a. Visual Studio Code Extension
    1. VS Code Marketplace: Karate

    2. Install from VS Code, click on the "Plugins" icon in the activity-bar and search for "karate".

      kl-install
    3. Make sure you choose the one from Karate Labs with a verified "blue tick".

  2. Create Project Folder

    Open a new project and create a folder if required. This is where you can place your Karate tests. Tests are in files with a *.feature extension. Here below, we created a project folder called karate-demo and we are now creating a file called httpbin.feature.

    kl-install
  3. Create First API Call

    Cut and paste the following text into the new file you created. This is a simple HTTP POST call to a URL at https://httpbin.org.

    Feature: Scenario:
    • * url 'https://httpbin.org/anything'
    • * request { myKey: 'myValue' }
    • * method post
    kl-install
  4. Run Karate Script

    Now click on the Run "codelens" to run the test:

    kl-install
  5. View HTML Report

    The "Output" tab should be visible with the log of all the HTTP calls and test results. Click on the link as shown below to open the HTML report.

    kl-install
  6. Add an Assertion

    Add the following 2 lines to the test script, you can cut-and-paste from the text below. This is an easy to read check if the HTTP status code in the response is 200 and whether the JSON returned in the API response contains the data expected.

    kl-install

    You can re-run the test and make sure the assertions pass. Change the 200 or the myValue to see what happens if an assertion fails. Refresh the HTML report in the browser to see what a failure looks like in the HTML report.

;