Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

How to Create Decision Points in JMeter Scripts?

DZone's Guide to

How to Create Decision Points in JMeter Scripts?

Check out how JMeter can add decision points to your perfromance tests for more precise results and more targeted analysis.

· Performance Zone ·
Free Resource

Sensu is an open source monitoring event pipeline. Try it today.

Performance test scenarios are not like the automated test scenarios. While automated test scripts focus on a few functionalities, performance test scenarios might be focused on more functionalities.

There might be some unexpected conditions in your scenarios and you have to take the necessary actions to resolve them. To deal with them effectively it is advised that you add decision points in your scripts.

Apache JMeter allows you to create decision points in your test scripts.

First of all, you need to analyze the response and take an action to it.

  • Create an HTTP request sampler
  • Attach a response extractor as a child element to the sampler. This response extractor might be any extractor.

load_testing

This in this example, we have used a CSS Extractor. It will fetch values in your HTML via  [data-name=’brand’] expression. Then it will find this web element’s data-href attribute and assign it to the brandLink variable. In case there are no results, the variable will be set to noBrand.

  • Add If Controller to your Test Plan
  • Condition field accepts Javascript so add  “${brandLink}” == “noBrand”  or  “${brandLink}” != “noBrand” , depending on your preference. This is our decision point. This usage might differ in JMeter versions.

performance test

  • Then add a new HTTP sampler as a child element to this IfController. The request will be executed according to the decision point.

Now you have a test plan as follows. If If Brand Controller returns True, a new request will be executed. If it’s set to False, it won’t make any more requests.

performance test

By having an If-Else condition you will enrich your test plans.

Please feel free to ask questions if you have any.

Happy load testing…

Sensu: workflow automation for monitoring. Learn more—download the whitepaper.

Topics:
jmeter ,jmeter functions ,load testing ,performance testing ,decision making ,performance ,automated testing ,decision points

Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}