SPONSORS:






View RSS Feed

Ronak

Understanding JMeter Element- If Controller

Rate this Entry
by , 06-21-2015 at 02:34 AM (1027 Views)
Understanding JMeter Element- If Controller

The If Controller allows the user to control whether the test elements below it (its children) are run or not.

JMeter allows the script to be processed as a variable expression, rather than requiring Javascript. It was always possible to use functions and variables in the Javascript condition, so long as they evaluated to "true" or "false"; now this can be done without the overhead of using Javascript as well. For example, previously one could use the condition: ${__jexl(${VAR} == 50)} and this would be evaluated as true/false, the result would then be passed to Javascript which would then return true/false. If the Variable Expression option is selected, then the expression is evaluated and compared with "true", without needing to use Javascript. Also, variable expressions can return any value, whereas the Javascript condition must return "true"/"false" or an error is logged.

No variables are made available to the script when the condition is interpreted as Javascript. If you need access to such variables, then select "Interpret Condition as Variable Expression?" and use a __javaScript() function call. You can then use the objects "vars", "log", "ctx" etc. in the script.
To test if a variable is undefined (or null) do the following, suppose var is named sampleVar, expression will be:
"${sampleVar}" == "\${sampleVar}"
Or use:
"${sampleVar}" != "\${sampleVar}"
to test if a variable is defined and is not null.

Parameters

Name- Descriptive name for this controller that is shown in the tree.
Condition (default Javascript)- By default the condition is interpreted as Javascript code that returns "true" or "false", but this can be overriden (see below)
Interpret Condition as Variable Expression? - If this is selected, then the condition must be an expression that evaluates to "true" (case is ignored). For example, ${FOUND} or ${__jexl(${VAR} > 500)}. Unlike the Javascript case, the condition is only checked to see if it matches "true" (case is ignored).
Evaluate for all children- Should condition be evaluated for all children? If not checked, then the condition is only evaluated on entry.
Examples (Javascript):
${COUNT} < 30
"${VAR}" == "abcdefg"
${JMeterThread.last_sample_ok} (check if last sample succeeded)
If there is an error interpreting the code, the condition is assumed to be false, and a message is logged in jmeter.log.
Examples (Variable Expression):
${__jexl(${COUNT} < 50)}
${RESULT}




Disclaimer: The article/post is posted with the purpose of sharing knowledge and information.
The article may contain references, extract or content from other informative sources.
Researched/Authored/Compiled by -
Ronak Shah
Practice Head - Software Testing (QA), CIGNEX Datamatics

vBulletin Optimisation provided by vB Optimise v2.6.0 Beta 4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.0.9 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Questions / Answers Form provided by vBAnswers (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
vBNominatevBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Username Changing provided by Username Change (Free) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
BetaSoft Inc.
Digital Point modules: Sphinx-based search
All times are GMT -8. The time now is 12:23 AM.

Copyright BetaSoft Inc.