Skip to content

Commit

Permalink
Step 2 : lets test some api
Browse files Browse the repository at this point in the history
  • Loading branch information
vparashar committed Sep 8, 2019
1 parent 1806bcc commit 9ceb02e
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
.idea
target/**
7 changes: 7 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@
<version>0.9.4</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down
10 changes: 10 additions & 0 deletions src/test/java/parashar/vijay/karate/demo/RunTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package parashar.vijay.karate.demo;

import com.intuit.karate.KarateOptions;
import com.intuit.karate.junit4.Karate;
import org.junit.runner.RunWith;

@RunWith(Karate.class)
@KarateOptions(features = "classpath:features/hello-world.feature")
public class RunTest {
}
10 changes: 10 additions & 0 deletions src/test/resources/features/hello-world.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Feature: Demo basic usage of karate

Scenario: make a get call to rest api and assert JSON Body
Given url 'https://httpbin.org'
And path 'get'
And param msg = "Lets Test api with Karate"
When method get
Then status 200
And match response.args == {"msg":"Lets Test api with Karate"}
And match response.headers.Host == '#string'
4 changes: 4 additions & 0 deletions src/test/resources/karate-config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
function() {
var config = {};
return config;
}
23 changes: 23 additions & 0 deletions src/test/resources/logback-test.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration>

<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>

<appender name="FILE" class="ch.qos.logback.core.FileAppender">
<file>target/karate.log</file>
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>

<logger name="com.intuit" level="DEBUG"/>

<root level="INFO">
<appender-ref ref="STDOUT" />
</root>

</configuration>

0 comments on commit 9ceb02e

Please sign in to comment.