Postman (REST Client) Tests

Veröffentlicht am 31.10.2014, 16:04 Uhr

### VORBEREITUNG ###

// save response in env
var data = responseBody;
postman.setEnvironmentVariable("data", data);

// parse value from json and save in env
var data = JSON.parse(responseBody);
postman.setEnvironmentVariable("device_id", data.id);

// parse array from json and safe as string and save in env
var data = JSON.parse(responseBody);
var product = JSON.stringify(data[0]);
postman.setEnvironmentVariable("contentful", product);

// parse array from json, change value, and safe as string and save in env
var data = JSON.parse(responseBody);
data.locale = "en_US";
var device_update = JSON.stringify(data);
postman.setEnvironmentVariable("device_update", device_update);


### TESTS ###

// test resposonse code
tests["Status code is 200"] = responseCode.code === 200;

// test if response is empty
var data = JSON.parse(responseBody);
tests["Transaction list is empty"] = data.length === 0;

// test if body contains value
tests["Body contains string" + environment.device_id] = responseBody.has(environment.device_id);

// test exact values of json
var data = JSON.parse(responseBody);
tests["transaction.id is " + environment.transaction_id] = data.id === environment.transaction_id;
tests["transaction.state is IN_PROGRESS"] = data.state === "IN_PROGRESS";

Diskussion zum Artikel

» Selbst kommentieren

  1. Zum Artikel Postman (REST Client) Tests sind noch keine Kommentare vorhanden. Deine Meinung wäre jedoch willkommen!

Sorry, the comment form is closed at this time.


Fatal error: Uncaught Error: Call to undefined function wp_ftr_googlestats() in /www/htdocs/w012bf20/betamode.de/wp-content/themes/betamode/footer.php:19 Stack trace: #0 /www/htdocs/w012bf20/betamode.de/wp-includes/template.php(684): require_once() #1 /www/htdocs/w012bf20/betamode.de/wp-includes/template.php(643): load_template('/www/htdocs/w01...', true) #2 /www/htdocs/w012bf20/betamode.de/wp-includes/general-template.php(84): locate_template(Array, true) #3 /www/htdocs/w012bf20/betamode.de/wp-content/themes/betamode/index.php(43): get_footer() #4 /www/htdocs/w012bf20/betamode.de/wp-includes/template-loader.php(74): include('/www/htdocs/w01...') #5 /www/htdocs/w012bf20/betamode.de/wp-blog-header.php(19): require_once('/www/htdocs/w01...') #6 /www/htdocs/w012bf20/betamode.de/index.php(17): require('/www/htdocs/w01...') #7 {main} thrown in /www/htdocs/w012bf20/betamode.de/wp-content/themes/betamode/footer.php on line 19