Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
K
KarateFrameWork
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nazoor Ahmed Saleemi
KarateFrameWork
Commits
f8eb9b78
Commit
f8eb9b78
authored
Feb 20, 2023
by
Training Purpose
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Karate Frame Work 1st Commit
parents
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
205 additions
and
0 deletions
+205
-0
pom.xml
pom.xml
+70
-0
firstTest.feature
src/test/java/Features/firstTest.feature
+78
-0
request.json
src/test/java/Features/request.json
+5
-0
TestRunner.java
src/test/java/TestRunner.java
+15
-0
karate-config.js
src/test/java/karate-config.js
+30
-0
ExpectedOutput.json
src/test/resources/ExpectedOutput.json
+7
-0
No files found.
pom.xml
0 → 100644
View file @
f8eb9b78
<?xml version="1.0" encoding="UTF-8"?>
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<modelVersion>
4.0.0
</modelVersion>
<groupId>
org.example
</groupId>
<artifactId>
Karate
</artifactId>
<version>
1.0-SNAPSHOT
</version>
<properties>
<maven.compiler.source>
8
</maven.compiler.source>
<maven.compiler.target>
8
</maven.compiler.target>
<project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding>
<cucumber.version>
4.8.1
</cucumber.version>
</properties>
<dependencies>
<!-- https://mvnrepository.com/artifact/com.intuit.karate/karate-core -->
<dependency>
<groupId>
com.intuit.karate
</groupId>
<artifactId>
karate-core
</artifactId>
<version>
1.3.1
</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.intuit.karate/karate-apache -->
<dependency>
<groupId>
com.intuit.karate
</groupId>
<artifactId>
karate-apache
</artifactId>
<version>
0.9.6
</version>
<scope>
test
</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/com.intuit.karate/karate-junit4 -->
<dependency>
<groupId>
com.intuit.karate
</groupId>
<artifactId>
karate-junit4
</artifactId>
<version>
1.3.1
</version>
<scope>
test
</scope>
</dependency>
<!-- <dependency>-->
<!-- <groupId>io.cucumber</groupId>-->
<!-- <artifactId>cucumber-core</artifactId>-->
<!-- <version>${cucumber.version}</version>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>io.cucumber</groupId>-->
<!-- <artifactId>cucumber-junit</artifactId>-->
<!-- <version>${cucumber.version}</version>-->
<!-- </dependency>-->
</dependencies>
<build>
<testResources>
<testResource>
<directory>
src/test/java
</directory>
<excludes>
<exclude>
**/*.java
</exclude>
</excludes>
</testResource>
</testResources>
</build>
</project>
\ No newline at end of file
src/test/java/Features/firstTest.feature
0 → 100644
View file @
f8eb9b78
Feature
:
First Sample API Test
Background
:
*
url baseURL
*
header Accept = 'application/json'
*
def req_payload = read('request.json')
Scenario
:
First Get Call
Given
path '/users?page=2'
When
method GET
Then
status 200
Scenario
:
Demo Get call 1
Given
path '/users'
When
param page = 2
When
method GET
Then
status 200
And
print response
And
print responseHeaders
And
print responseStatus
And
print responseTime
Scenario
:
Demo Get Call 2
Given
path '/users'
When
param page = 2
When
method GET
Then
status 200
And
print response
Then
assert response.data[0].first_name == 'Michael'
Then
match response.data[0].first_name == 'Michaelq'
Scenario
:
Demo Post Call 1
Given
path '/users'
And request {"name"
:
"nazoor","job"
:
"leader"}
When
method POST
Then
status 201
Then
print response
And match response == { "name"
:
"nazoor","job"
:
"leader","id"
:
"#string","createdAt"
:
"
#ignore"}
Scenario
:
Demo Post Call 2
Given
path '/users'
And
request req_payload
When
method POST
Then
status 201
Then
print response
And
def exp_payload = karate.properties['user.dir']+'/src/test/resources/ExpectedOutput.json'
And
print 'paht = '+exp_payload
And def exp = read('file
:
'+exp_payload)
And
print exp
And
match response == exp
Scenario
:
Demo Put Call 1
Given
path '/users/2'
And
request req_payload
When
method PUT
And
print response
Then
status 200
Scenario
:
Demo Patch Call 2
Given
path '/users/2'
And
request req_payload
When
method PATCH
And
print response
Then
status 200
Scenario
:
Demo Delete Call 1
Given
path '/users/2'
When
method DELETE
And
print response
Then
status 204
Scenario
:
Demo Karate Config file
Given
print name
When
print baseURL
src/test/java/Features/request.json
0 → 100644
View file @
f8eb9b78
{
"name"
:
"nazoor"
,
"job"
:
"leader"
}
\ No newline at end of file
src/test/java/TestRunner.java
0 → 100644
View file @
f8eb9b78
import
com.intuit.karate.junit4.Karate
;
import
org.junit.BeforeClass
;
import
org.junit.runner.RunWith
;
@RunWith
(
Karate
.
class
)
public
class
TestRunner
{
@BeforeClass
public
static
void
before
()
{
System
.
setProperty
(
"karate.env"
,
"QA1"
);
}
}
\ No newline at end of file
src/test/java/karate-config.js
0 → 100644
View file @
f8eb9b78
function
fn
(){
var
config
=
{
name
:
"Nazoor"
,
baseURL
:
"https://reqres.in/api"
};
karate
.
log
(
'The Value of name is : '
,
config
.
name
);
karate
.
log
(
'The Value of baseURL is : '
,
config
.
baseURL
);
var
env
=
karate
.
env
;
karate
.
log
(
'The Value of env is : '
,
env
);
karate
.
configure
(
'connectTimeout'
,
5000
);
karate
.
configure
(
'readTimeout'
,
5000
);
if
(
env
==
'QA1'
)
{
config
.
baseURL
=
'https://reqres.in/api/'
;
}
else
if
(
env
==
'QA2'
){
config
.
baseURL
=
'https://reqres.in/api/'
;
}
karate
.
log
(
'Base URL = '
,
config
.
baseURL
)
return
config
;
}
\ No newline at end of file
src/test/resources/ExpectedOutput.json
0 → 100644
View file @
f8eb9b78
{
"name"
:
"nazoor"
,
"job"
:
"leader"
,
"id"
:
"#string"
,
"createdAt"
:
"#ignore"
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment