Jmeter - BeanShell assertion is not running

685 Views Asked by At

When running the thread, it goes through the whole flow except for the last BeanShell assertion.

enter image description here

My BeanShell code is:

report = vars.get("status_1");

if (report=="active") {

 Failure = true;
 FailureMessage = "failed to report";

} else {

    Failure = false;


}

What could go wrong?

2

There are 2 best solutions below

3
On BEST ANSWER

You are comparing String using == you must use .equals() method to compare them.

That is generally true, not just for beanshell, but for most of the java world. Always be careful about how you compare strings. see How do I compare strings in Java?

0
On

You can either use .equals() or boolean

 boolean report = vars.get("status_1");

 if (report) {

    Failure = true;
    FailureMessage = "failed to report";

  } else {

  Failure = false;


}