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
11d06dfa
Commit
11d06dfa
authored
Mar 06, 2023
by
Training Purpose
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allure Report Integration
parent
4d3d8096
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
146 additions
and
78 deletions
+146
-78
pom.xml
pom.xml
+51
-13
firstTest.feature
src/test/java/Features/firstTest.feature
+58
-56
test1.feature
src/test/java/Features/test1.feature
+12
-0
TestRunner.java
src/test/java/TestRunner.java
+3
-1
karate-config.js
src/test/java/karate-config.js
+21
-8
allure.properties
src/test/resources/allure.properties
+1
-0
No files found.
pom.xml
View file @
11d06dfa
...
...
@@ -12,8 +12,9 @@
<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>
<!-- <cucumber.version>4.8.1</cucumber.version>-->
<aspectj.version>
1.8.10
</aspectj.version>
<allure.version>
2.10.0
</allure.version>
</properties>
...
...
@@ -41,29 +42,66 @@
<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>-->
<!-- https://mvnrepository.com/artifact/io.qameta.allure/allure-junit4 -->
<dependency>
<groupId>
io.qameta.allure
</groupId>
<artifactId>
allure-junit4
</artifactId>
<version>
${allure.version}
</version>
</dependency>
<dependency>
<groupId>
io.qameta.allure
</groupId>
<artifactId>
allure-java-commons
</artifactId>
<version>
${allure.version}
</version>
</dependency>
<dependency>
<groupId>
io.qameta.allure
</groupId>
<artifactId>
allure-model
</artifactId>
<version>
${allure.version}
</version>
</dependency>
</dependencies>
<build>
<testResources>
<testResource>
<directory>
src/test/java
</directory>
<filtering>
true
</filtering>
<excludes>
<exclude>
**/*.java
</exclude>
</excludes>
</testResource>
</testResources>
<plugins>
<plugin>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-surefire-plugin
</artifactId>
<version>
2.22.2
</version>
<configuration>
<testFailureIgnore>
false
</testFailureIgnore>
<argLine>
-javaagent:"${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar"
</argLine>
<properties>
<property>
<name>
listener
</name>
<value>
io.qameta.allure.junit4.AllureJunit4
</value>
</property>
</properties>
</configuration>
<dependencies>
<dependency>
<groupId>
org.aspectj
</groupId>
<artifactId>
aspectjweaver
</artifactId>
<version>
${aspectj.version}
</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</project>
\ No newline at end of file
src/test/java/Features/firstTest.feature
View file @
11d06dfa
...
...
@@ -5,71 +5,73 @@ Feature: First Sample API Test
*
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
@nazoor
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
@nazoor
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 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 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 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 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 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 Delete Call 1
Given
path '/users/2'
When
method DELETE
And
print response
Then
status 204
Scenario
:
Demo Karate Config file
...
...
src/test/java/Features/test1.feature
0 → 100644
View file @
11d06dfa
Feature
:
Test Feature
Background
:
*
url baseURL
*
header Accept = 'application/json'
*
def req_payload = read('request.json')
@nazoor
Scenario
:
Demo Karate Config file
Given
print name
When
print baseURL
When
print baseURL
\ No newline at end of file
src/test/java/TestRunner.java
View file @
11d06dfa
import
com.intuit.karate.KarateOptions
;
import
com.intuit.karate.junit4.Karate
;
import
org.junit.BeforeClass
;
import
org.junit.runner.RunWith
;
@RunWith
(
Karate
.
class
)
public
class
TestRunner
{
public
class
TestRunner
{
@BeforeClass
...
...
src/test/java/karate-config.js
View file @
11d06dfa
...
...
@@ -13,14 +13,27 @@ function fn(){
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/'
;
}
switch
(
env
)
{
case
'QA1'
:
config
.
baseURL
=
'https://reqres.in/api/'
;
break
;
case
'QA2'
:
config
.
baseURL
=
'https://reqres.in/api/'
;
break
;
default
:
config
.
baseURL
=
'https://reqres.in/api/'
;
break
;
}
// 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
)
...
...
src/test/resources/allure.properties
0 → 100644
View file @
11d06dfa
allure.results.directory
=
allure-results
\ 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