Jmeter - BeanShell assertion is not running

662 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 answers

3
RaGe 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
AudioBubble 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;


}