Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add 'Or' condition in assertion

Tags:

jmeter

I want the request to pass in both the cases if response contains "Completed" or "Progress, Will take time to process".

But if I include both this assertions in response assertion, it will take it as 'and'. It will pass only if both are satisfied. Here any one of this is sufficient. Please suggest.

like image 861
Aajan Avatar asked Mar 13 '23 18:03

Aajan


1 Answers

You will need to go for an assertion which supports scripting, i.e. Beanshell Assertion

  1. Add Beanshell Assertion as a child of the request which returns either "Completed" or "Progress" messages
  2. Put the following code into "Script" area:

    String response = new String(ResponseData);
    
    Failure = !(response.contains("Completed") || response.contains("Progress, Will take time to process"));
    

    Where:

    • ResponseData - byte array which holds parent sampler response
    • Failure - boolean which indicates whether parent sampler should be failed or not.

See How to Use BeanShell: JMeter's Favorite Built-in Component guide for more information on how to use JMeter and Java API from Beanshell test elements and extend your JMeter tests with scripting.

like image 72
Dmitri T Avatar answered Apr 27 '23 02:04

Dmitri T