17:30:35.244 karate.env system property was: demo
Feature: Report with JSON rest response
Description: Report with JSON rest response
File name: starwars.feature
Relative path: starwars.feature
@dojo
Scenario: Create an API test that returns all the planets in the SW. Validate that ALL returns are as expected.
Given
path 'planets'
01:09:15.735
When
method get
01:07:40.535
17:30:35.402 request: 1 > GET https://swapi.co/api/planets 1 > Accept-Encoding: gzip,deflate 1 > Connection: Keep-Alive 1 > Host: swapi.co 1 > User-Agent: Apache-HttpClient/4.5.5 (Java/1.8.0_242) 17:30:38.408 response time in milliseconds: 3002.61 1 < 301 1 < CF-Cache-Status: DYNAMIC 1 < CF-RAY: 560eda61f8296b6b-LHR 1 < Connection: keep-alive 1 < Content-Type: text/html; charset=utf-8 1 < Date: Thu, 06 Feb 2020 17:30:38 GMT 1 < Expect-CT: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct" 1 < Location: https://swapi.co/api/planets/ 1 < Server: cloudflare 1 < Set-Cookie: __cfduid=da2652607b9b30b4e232d4a0a253db7111581010237; expires=Sat, 07-Mar-20 17:30:37 GMT; path=/; domain=.swapi.co; HttpOnly; SameSite=Lax; Secure 1 < Transfer-Encoding: chunked 1 < Via: 1.1 vegur 1 < X-Frame-Options: SAMEORIGIN 17:30:38.411 request: 2 > GET https://swapi.co/api/planets 2 > Accept-Encoding: gzip,deflate 2 > Connection: Keep-Alive 2 > Cookie: __cfduid=da2652607b9b30b4e232d4a0a253db7111581010237 2 > Host: swapi.co 2 > User-Agent: Apache-HttpClient/4.5.5 (Java/1.8.0_242) 17:30:39.317 response time in milliseconds: 903.69 2 < 200 2 < Allow: GET, HEAD, OPTIONS 2 < CF-Cache-Status: DYNAMIC 2 < CF-RAY: 560eda66beab6b6b-LHR 2 < Connection: keep-alive 2 < Content-Type: application/json 2 < Date: Thu, 06 Feb 2020 17:30:39 GMT 2 < Etag: W/"394d177de8df8accc41f9427b749ef4a" 2 < Expect-CT: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct" 2 < Server: cloudflare 2 < Transfer-Encoding: chunked 2 < Vary: Accept, Cookie 2 < Via: 1.1 vegur 2 < X-Frame-Options: SAMEORIGIN {"count":61,"next":"https://swapi.co/api/planets/?page=2","previous":null,"results":[{"name":"Alderaan","rotation_period":"24","orbital_period":"364","diameter":"12500","climate":"temperate","gravity":"1 standard","terrain":"grasslands, mountains","surface_water":"40","population":"2000000000","residents":["https://swapi.co/api/people/5/","https://swapi.co/api/people/68/","https://swapi.co/api/people/81/"],"films":["https://swapi.co/api/films/6/","https://swapi.co/api/films/1/"],"created":"2014-12-10T11:35:48.479000Z","edited":"2014-12-20T20:58:18.420000Z","url":"https://swapi.co/api/planets/2/"},{"name":"Yavin IV","rotation_period":"24","orbital_period":"4818","diameter":"10200","climate":"temperate, tropical","gravity":"1 standard","terrain":"jungle, rainforests","surface_water":"8","population":"1000","residents":[],"films":["https://swapi.co/api/films/1/"],"created":"2014-12-10T11:37:19.144000Z","edited":"2014-12-20T20:58:18.421000Z","url":"https://swapi.co/api/planets/3/"},{"name":"Hoth","rotation_period":"23","orbital_period":"549","diameter":"7200","climate":"frozen","gravity":"1.1 standard","terrain":"tundra, ice caves, mountain ranges","surface_water":"100","population":"unknown","residents":[],"films":["https://swapi.co/api/films/2/"],"created":"2014-12-10T11:39:13.934000Z","edited":"2014-12-20T20:58:18.423000Z","url":"https://swapi.co/api/planets/4/"},{"name":"Dagobah","rotation_period":"23","orbital_period":"341","diameter":"8900","climate":"murky","gravity":"N/A","terrain":"swamp, jungles","surface_water":"8","population":"unknown","residents":[],"films":["https://swapi.co/api/films/2/","https://swapi.co/api/films/6/","https://swapi.co/api/films/3/"],"created":"2014-12-10T11:42:22.590000Z","edited":"2014-12-20T20:58:18.425000Z","url":"https://swapi.co/api/planets/5/"},{"name":"Bespin","rotation_period":"12","orbital_period":"5110","diameter":"118000","climate":"temperate","gravity":"1.5 (surface), 1 standard (Cloud City)","terrain":"gas giant","surface_water":"0","population":"6000000","residents":["https://swapi.co/api/people/26/"],"films":["https://swapi.co/api/films/2/"],"created":"2014-12-10T11:43:55.240000Z","edited":"2014-12-20T20:58:18.427000Z","url":"https://swapi.co/api/planets/6/"},{"name":"Endor","rotation_period":"18","orbital_period":"402","diameter":"4900","climate":"temperate","gravity":"0.85 standard","terrain":"forests, mountains, lakes","surface_water":"8","population":"30000000","residents":["https://swapi.co/api/people/30/"],"films":["https://swapi.co/api/films/3/"],"created":"2014-12-10T11:50:29.349000Z","edited":"2014-12-20T20:58:18.429000Z","url":"https://swapi.co/api/planets/7/"},{"name":"Naboo","rotation_period":"26","orbital_period":"312","diameter":"12120","climate":"temperate","gravity":"1 standard","terrain":"grassy hills, swamps, forests, mountains","surface_water":"12","population":"4500000000","residents":["https://swapi.co/api/people/3/","https://swapi.co/api/people/21/","https://swapi.co/api/people/36/","https://swapi.co/api/people/37/","https://swapi.co/api/people/38/","https://swapi.co/api/people/39/","https://swapi.co/api/people/42/","https://swapi.co/api/people/60/","https://swapi.co/api/people/61/","https://swapi.co/api/people/66/","https://swapi.co/api/people/35/"],"films":["https://swapi.co/api/films/5/","https://swapi.co/api/films/4/","https://swapi.co/api/films/6/","https://swapi.co/api/films/3/"],"created":"2014-12-10T11:52:31.066000Z","edited":"2014-12-20T20:58:18.430000Z","url":"https://swapi.co/api/planets/8/"},{"name":"Coruscant","rotation_period":"24","orbital_period":"368","diameter":"12240","climate":"temperate","gravity":"1 standard","terrain":"cityscape, mountains","surface_water":"unknown","population":"1000000000000","residents":["https://swapi.co/api/people/34/","https://swapi.co/api/people/55/","https://swapi.co/api/people/74/"],"films":["https://swapi.co/api/films/5/","https://swapi.co/api/films/4/","https://swapi.co/api/films/6/","https://swapi.co/api/films/3/"],"created":"2014-12-10T11:54:13.921000Z","edited":"2014-12-20T20:58:18.432000Z","url":"https://swapi.co/api/planets/9/"},{"name":"Kamino","rotation_period":"27","orbital_period":"463","diameter":"19720","climate":"temperate","gravity":"1 standard","terrain":"ocean","surface_water":"100","population":"1000000000","residents":["https://swapi.co/api/people/22/","https://swapi.co/api/people/72/","https://swapi.co/api/people/73/"],"films":["https://swapi.co/api/films/5/"],"created":"2014-12-10T12:45:06.577000Z","edited":"2014-12-20T20:58:18.434000Z","url":"https://swapi.co/api/planets/10/"},{"name":"Geonosis","rotation_period":"30","orbital_period":"256","diameter":"11370","climate":"temperate, arid","gravity":"0.9 standard","terrain":"rock, desert, mountain, barren","surface_water":"5","population":"100000000000","residents":["https://swapi.co/api/people/63/"],"films":["https://swapi.co/api/films/5/"],"created":"2014-12-10T12:47:22.350000Z","edited":"2014-12-20T20:58:18.437000Z","url":"https://swapi.co/api/planets/11/"}]}
Then
status 200
00:00:09.140
*
def json = read('planetas.json')
01:02:52.894
And
match json == response
00:08:16.304