This repository contains API automation scripts developed using Karate-JUnit5
Framework in Java
, to test the functionalities of the Pet Store API available at Swagger Pet Store.
- Java Development Kit (JDK) 11.0.20 installed
- Maven build tool installed
-
src/test/java
: Contains the Karate test scripts java runner.src └── test └── java ├── com │ └── api │ └── automation │ ├── 1postCreateUser.feature │ ├── 1postCreateUserWithList.feature │ ├── 2getLoginRequest.feature │ ├── 2getLogoutRequest.feature │ ├── 2getUserNameRequest.feature │ ├── 3putUpdateUser.feature │ ├── RunAllTest.java --> to run all test │ ├── Runner.java --> run single test │ └── deleteRequest.feature ├── karate-config.js └── logback-test.xml
-
target
: Generated reports and logs.target ├── karate-reports
Add the following to your pom.xml
<dependency>
- Karate-JUnit5 1.4.1
<!-- https://mvnrepository.com/artifact/com.intuit.karate/karate-junit5 -->
<dependency>
<groupId>com.intuit.karate</groupId>
<artifactId>karate-junit5</artifactId>
<version>1.4.1</version>
<scope>test</scope>
</dependency>
- Jackson Core 2.12.0
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.12.0</version>
</dependency>
- json-schema-validator 2.2.14
<dependency>
<groupId>com.github.java-json-tools</groupId>
<artifactId>json-schema-validator</artifactId>
<version>2.2.14</version>
</dependency>
-
Review the test scripts available in
src/test/java
. -
Run the JUnit
Runner
file directly from the IDE, I'm using IntelliJ IDEA, or run using the terminal using this commandmvn test -Dtest="Runner"
This is for running all the karate
.feature
filemvn test -Dtest="RunAllTest"
-
By integrating with the JUnit framework we can quickly see what failed and the corresponding error message without having to dive into logs / HTML reports, with Karate will also create a
.html
report