Jmeter If controller is very useful in any software application's load testing using jmeter. If controller in jmeter allows you to set condition to evaluate it and based on condition evaluation result it will decide to run or not to run if controller's child elements. jmeter if controller's if condition evaluation result is positive then child elements of if controller will run else child elements of if controller will not run. Let's see sample software load testing plan to understand usage of if condition in jmeter. Also you can view Jmeter Logic controllers examples.
I have created sample software load testing plan to understand usage of If Controller in apache jmeter as jmeter if controller example below.
jmeter if controller example
Used number of threads = 1 and loop count = 1.
Under first Google Home Page request, I have added Regular Expression Extractor to extract software web application's page title of Google Home Page as shown in below image. When we run test, Result of Regular Expression Extractor will be "Google". That means it will store "Google" in Reference Name title.
Latter on we will learn more about Regular Expression Extractor.
You can see in below image, We have used condition "${title}"=="Yahoo" in first jmeter if controller. That means child element of 1st if controller will be executed only if value of title reference name is Yahoo. In this case it will be false as value of title reference name will be Google.
2nd if controller has "${title}"=="Google" condition. So child request of 2nd jmeter if controller will be executed.
Now if you will run above software application load testing plan, It will run child element of 2nd if controller in jmeter but child element of 1st jmeter if controller will be not executed as shown in below image.
So only 2 requests are executed out of 3 requests. This way you can use if controller in any software web application's load testing plan.
No comments:
Post a Comment