Skip to content

Commit d22de46

Browse files
committedJan 16, 2022
added json file feature file
1 parent 90802f3 commit d22de46

22 files changed

+676
-62
lines changed
 

‎.classpath

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
<attribute name="test" value="true"/>
1414
</attributes>
1515
</classpathentry>
16+
<classpathentry kind="src" path="src/test/resources"/>
1617
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
1718
<attributes>
1819
<attribute name="maven.pomderived" value="true"/>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
Feature: Create user using post api
2+
3+
Background:
4+
* url 'https://gorest.co.in'
5+
* def random_string =
6+
"""
7+
function(s){
8+
var text = "";
9+
var pattern = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
10+
for(var i=0; i<s; i++)
11+
text += pattern.charAt(Math.floor(Math.random() * pattern.length()));
12+
return text;
13+
}
14+
"""
15+
* def randomString = random_string(10)
16+
* print randomString
17+
18+
* def requestPayload = read('classpath:src/test/resources/payload/user.json')
19+
20+
* set requestPayload.email = randomString + "@gmail.com"
21+
22+
* print requestPayload
23+
24+
25+
Scenario: Create a user with the given data
26+
Given path '/public/v1/users'
27+
And request requestPayload
28+
And header Authorization = 'Bearer ' + tokenID
29+
When method post
30+
Then status 201
31+
And match $.data.id == '#present'
32+
And match $.data.name == '#present'
33+
And match $.data.name == 'tom'
34+
And match $.data.email == requestPayload.email

‎src/test/java/features/randommail.feature

+4-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Feature: Create user using post api
22

33
Background:
44
* url 'https://gorest.co.in'
5-
5+
66
* def random_string =
77
"""
88
function(s){
@@ -24,7 +24,9 @@ Background:
2424
"status": "active"
2525
}
2626
"""
27-
* requestPayload.email = randomString + "@gmail.com"
27+
# * requestPayload.email = randomString + "@gmail.com"
28+
* set requestPayload.email = randomString + "@gmail.com"
29+
2830
* print requestPayload
2931

3032
Scenario: Create a user with the given data

‎src/test/resources/payload/user.json

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"name": "tom",
3+
"gender": "male",
4+
"status": "active"
5+
}

‎target/ForkJoinPool-1-worker-1.log

+15-17
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
20:17:25.109 [print] lKBlBSTHwF
2-
20:17:25.121 [print] {
1+
14:32:26.807 [print] osLkkPLlPP
2+
14:32:26.815 [print] {
33
"name": "tom",
44
"gender": "male",
55
"status": "active",
6-
"email": "lKBlBSTHwF@gmail.com"
6+
"email": "osLkkPLlPP@gmail.com"
77
}
88

9-
20:17:25.491 request:
9+
14:32:27.133 request:
1010
1 > POST https://gorest.co.in/public/v1/users
1111
1 > Accept-Encoding: gzip,deflate
1212
1 > Authorization: Bearer 007526d9efdbc07e084ff7a6d4cfcc90588fbe20641c00faebf45a7f3b2eaf33
@@ -15,16 +15,16 @@
1515
1 > Content-Type: application/json; charset=UTF-8
1616
1 > Host: gorest.co.in
1717
1 > User-Agent: Apache-HttpClient/4.5.12 (Java/1.8.0_261)
18-
{"name":"tom","gender":"male","status":"active","email":"lKBlBSTHwF@gmail.com"}
18+
{"name":"tom","gender":"male","status":"active","email":"osLkkPLlPP@gmail.com"}
1919

20-
20:17:25.895 response time in milliseconds: 401.50
20+
14:32:28.627 response time in milliseconds: 1492.33
2121
1 < 201
2222
1 < Cache-Control: max-age=0, private, must-revalidate
2323
1 < Connection: keep-alive
2424
1 < Content-Type: application/json; charset=utf-8
25-
1 < Date: Thu, 30 Dec 2021 14:47:25 GMT
26-
1 < ETag: W/"6a7c507c13e83c0869c970538456df6e"
27-
1 < Location: https://gorest.co.in/public/v1/users/6663
25+
1 < Date: Sun, 16 Jan 2022 10:32:28 GMT
26+
1 < ETag: W/"ab32704018ba4f49b49c2eb39156f91c"
27+
1 < Location: https://gorest.co.in/public/v1/users/1703
2828
1 < Referrer-Policy: strict-origin-when-cross-origin
2929
1 < Server: nginx
3030
1 < Strict-Transport-Security: max-age=63072000; includeSubDomains
@@ -34,15 +34,13 @@
3434
1 < X-Download-Options: noopen
3535
1 < X-Frame-Options: SAMEORIGIN
3636
1 < X-Permitted-Cross-Domain-Policies: none
37-
1 < X-Request-Id: 042c772c-7379-4654-9601-7c63550e1f7f
38-
1 < X-Runtime: 0.018166
39-
1 < X-XSS-Protection: 0
40-
{"meta":null,"data":{"id":6663,"name":"tom","email":"lKBlBSTHwF@gmail.com","gender":"male","status":"active"}}
37+
1 < X-Request-Id: 02992b4c-4433-48ba-901c-3794ba9d0303
38+
1 < X-Runtime: 0.014061
39+
1 < X-XSS-Protection: 1; mode=block
40+
{"meta":null,"data":{"id":1703,"name":"tom","email":"osLkkPLlPP@gmail.com","gender":"male","status":"active"}}
4141

42-
c/v1/users/30
43-
1 > Accept-Encoding: gzip,deflate
44-
1 > Connection: Keep-Alive
45-
1 > Content-Type: text/xml;charset=ISO-8859-1
42+
ath: $.data.email, actual: 'cjYVrIgiDd@gmail.com', expected: 'tom24@gmail.com', reason: not equal
43+
SO-8859-1
4644
1 > Host: gorest.co.in
4745
1 > User-Agent: Mozilla/4.0(compatible;IE;GACv7 1 5192 22378)
4846

‎target/classes/payload/user.json

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"name": "tom",
3+
"gender": "male",
4+
"status": "active"
5+
}

‎target/surefire-reports/karate-summary.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747

4848
<div id="nav-type">Features</div>
4949

50-
<div id="nav-date">2021-12-30 08:17:24 PM</div>
50+
<div id="nav-date">2022-01-16 02:32:26 PM</div>
5151

5252
<div class="nav-container"></div>
5353
</div>
@@ -65,7 +65,7 @@
6565
</thead>
6666
<tbody>
6767
<tr class="passed-lt">
68-
<td><a href="src.test.java.features.randommail.html">src/test/java/features/randommail.feature</a></td><td>Create user using post api</td><td class="num">1</td><td class="num">0</td><td class="num">1</td><td class="num">824</td>
68+
<td><a href="src.test.java.features.postjsonfile.html">src/test/java/features/postjsonfile.feature</a></td><td>Create user using post api</td><td class="num">1</td><td class="num">0</td><td class="num">1</td><td class="num">1856</td>
6969
</tr>
7070
</tbody>
7171
</table>

‎target/surefire-reports/karate-tags.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747

4848
<div id="nav-type">Tags</div>
4949

50-
<div id="nav-date">2021-12-30 08:17:24 PM</div>
50+
<div id="nav-date">2022-01-16 02:32:26 PM</div>
5151

5252
<div class="nav-container"></div>
5353
</div>
@@ -65,7 +65,7 @@
6565
</thead>
6666
<tbody>
6767
<tr>
68-
<td class="feature-cell"><a class="" href="src.test.java.features.randommail.html">src/test/java/features/randommail.feature</a></td>
68+
<td class="feature-cell"><a class="" href="src.test.java.features.postjsonfile.html">src/test/java/features/postjsonfile.feature</a></td>
6969
</tr>
7070
</tbody>
7171
</table>
+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"features":1,"ignored":0,"efficiency":0.5405064967191601,"failures":null,"totalTime":823.731901,"threads":1,"scenarios":1,"failed":0,"passed":1,"version":"0.9.6","elapsedTime":1524.0}
1+
{"features":1,"ignored":0,"efficiency":0.7461340136710897,"failures":null,"totalTime":1855.635292,"threads":1,"scenarios":1,"failed":0,"passed":1,"version":"0.9.6","elapsedTime":2487.0}

0 commit comments

Comments
 (0)
Please sign in to comment.