Thursday, 9 July 2020

KARATE (API TESTING) BASICS

KARATE API Testing Basics:

Karate , I started with Intellij IDE . I added the required dependencies in Maven. I started creating a new Maven Project and click on Add Archetypes. I have given below information in the small popup

Archetype Group Id= com.intuit.karate
ArchetypeArtifactId= karate-archetype
ArchetypeVersion=0.2.7

Then I entered my project name and its created my first project. Then in the project explorer, i started creating my directory structure. In Karate directory structure becomes so important since we are going to deal with .feature files, and a java runner class and request and response Json files. So we need to arrange them in  a particular fashion so that the IDE picks it up from right location.

Before that , lets have a look at the Maven dependencies . Karate needs an integration with Junit to run the test cases. so we need to add / or make sure these dependencies are in place.

<dependencies>
<dependency>
<groupId>com.intuit.karate</groupId>
<artifactId>karate-apache</artifactId>
<version>${karate.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.intuit.karate</groupId>
<artifactId>karate-junit4</artifactId>
<version>${karate.version}</version>
<scope>test</scope>
</dependency>
</dependencies>


Here karate.version may be the current version of karate. The current version we can check it from Maven repository (https://mvnrepository.com/artifact/com.intuit.karate/karate-junit5)

At this point of time, the current stable version is 0.9.5 , that I updated into my maven dependencies like below
<dependency>
<groupId>com.intuit.karate</groupId>
<artifactId>karate-junit4</artifactId>
<version>0.9.5</version>
<scope>test</scope>
</dependency>

Now is the time to create folder structure:
Expand the project folders, expand src, and then Java. Now right click java and select new and package. Enter the name of the package
then in the package you can create sub folders requests, responses, if required features as a separate folder. 


Shrinking the size of Oracle Virtual Box

First, zero fill your virtual disk. Boot the VM and run: sudo dd if=/dev/zero of=/bigemptyfile bs=4096k status=progress sudo rm -f /bigempty...