I have two variable 1)Expected(taken from excel file) & 2)Actual(regex from result) Now i tried to compare both the variables using bean Shell Post processor Scripting.
if(("${Expected}").equals("${Actual}"))
{
IsSuccess = true;
}
else
{
IsSuccess = false;
}
which should actually mark sample as pass and fail according to the comparison. But i can't find the sampler marked fail when the comparison returns false. Is their any error in my condition. Also Please help to print output to console Help is appreciated. Thank You
Example suggested code:
if (vars.get("Expected").equals(vars.get("Actual"))) {
prev.setSuccessful(true);
}
else {
prev.setSuccessful(false);
}
Other recommendations:
You can achieve the same without having to write a single line of code via "normal" Response Assertion, example configuration would be something like:
See How to Use JMeter Assertions in Three Easy Steps article for more information on conditionally passing/failing your JMeter samplers using assertions.