0
votes

Scenario: I have 3 HTTP requests to make as follows:

Step1: Make request1 and use JSON extractor to extract a value from JSON response and store it in a variable say x

Step2: Make request2 and wait for 2minutes(I'm using Constant Timer).

Step3: Make request3 and use JSON extractor to extract a value from JSON response and store it in a variable say y

Step4: Compare 'x' and 'y' and Pass the test in jtl file if y > x else fail.

Issue: I'm not able to find out the way to complete step4.

1

1 Answers

0
votes

x and y are numbers insider JMeter variables, for step 4 use JSR223 PostProcessor as a post processor of request3,

In code convert variables to numbers and compare it as and if y >x fail the sampler:

x = vars.get("x");
y = vars.get("y");

if (Integer.parseInt(x) >=  Integer.parseInt(y)) {
    log.info("x is bigger than y, continue test");
} else {
    prev.setSuccessful(false);    
}

Example in Java/Beanshell language, but you can use groovy also.