Hi. Currently, I encountered a small problem.
I have a goal: to test counter(functionality that calculates numbers) in order to check this counter returns a number that falls under set range of low and high (Β±5% deviation)
Now, I have this piece of code:
var allLists = JSON.parse(responseBody);
var min = pm.variables.get("count"); // I separately extract min
var max = pm.variables.get("count1"); // and max, but want to extract one variable with min and max;
var low = parseInt(min)
var high = parseInt(max);
console.log("::MIN_VALIE: " + low + " | " + "::MAX_VALUE: " + high);
pm.test("test count", function () {
const value = allLists.data.count;
console.log(":::::::::=> COUNTER: " + value);
pm.expect(typeof value).to.eql('number');
pm.expect(value > low && value < high).to.eql(true);
});
It works ok, but I believe this code is bulky
In order to compare that value in the range of low and high I have to keep low and high number in separate collection variables, that out of desired 50 variables makes 100 variables and real mess.
Can I somehow keep one variable for low and high value in collection variables?
UPDATE: Right after posting came up with it:
var allLists = JSON.parse(responseBody);
var num = pm.variables.get("count").split(',');
var min = parseInt(num[0]);
var max = parseInt(num[1]);
console.log("::MIN_VALIE: " + min + " | " + "::MAX_VALUE: " + max);
pm.test("test count", function () {
const value = allLists.data.count;
console.log(":::::::::=> COUNTER: " + value);
pm.expect(typeof value).to.eql('number');
pm.expect(15 > min && 15 < max).to.eql(true);
});
itβs much better, but maybe exists better way