I'm trying to compare int (parse from string) to counter in BeanShell assertion.
my code:
int i = Integer.parseInt(vars.get("count_2"));
counter = vars.get("counter");
if (i != counter)
{
Failure = true;
FailureMessage = "failed";
} else {
Failure = false;
}
On debug sampler I can see that both "count_2" and "counter" have the same values in all loop runs, but the assertion fails.
What went wrong?
Option 1: use integers everywhere
Change this line:
To:
Option 2: use strings everywhere
JMeterVariables can be either Strings or Objects, so you need to cast them to the types you need to work with.
See How to use BeanShell: JMeter's favorite built-in component guide for essential information on scripting in JMeter and some form of cookbook.