Reputation: 814
if(!reqAdSize.equalsIgnoreCase(hm.get("ad_size")))
{
Failure = true;
FailureMessage = "Ad Sizes Doesn't Match";
}
if(!reqCur.equalsIgnoreCase(resCur))
{
Failure = true;
FailureMessage = "Request & Responce Currency are NOT same";
}
if(!reqID.equalsIgnoreCase(resID))
{
Failure = true;
FailureMessage = "Request & Responce Id is NOT same";
}
In my jeMter here is my BeanShell Assertion Code all if conditions are satisfying.
In result it will showing the last FailureMessage. I need to stop the execution of code if first condition is true and it will not execute further.
I tried to use the System.exit(0);
andexit();
. But jMeter GUI is automatically closing.
What is the method to stop the execution at current line in BeanShell.
Upvotes: 3
Views: 1565
Reputation: 6398
Add return
keyword wherever you want to stop the execution of BeanShell code.
Upvotes: 3
Reputation: 167992
You have SampleResult
pre-defined variable in the Beanshell Assertion, it is a shorthand for org.apache.jmeter.samplers.SampleResult class. Take a look into following methods:
Something like:
if (!reqAdSize.equalsIgnoreCase(hm.get("ad_size"))) {
Failure = true;
FailureMessage = "Ad Sizes Doesn't Match";
SampleResult.setStopTest(true);
}
Guide on Beanshell scripting in JMeter context: How to Use BeanShell: JMeter's Favorite Built-in Component
Upvotes: 0