You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jmeter.apache.org by Philippe Mouawad <pm...@apache.org> on 2012/10/11 22:18:27 UTC

Testing for nullity in IfController

Hello,
I was wondering if there isn't a better way to do this, which I don't like
very much.

Regards
Philippe
On Thu, Oct 11, 2012 at 10:15 PM, <pm...@apache.org> wrote:

> Author: pmouawad
> Date: Thu Oct 11 20:15:36 2012
> New Revision: 1397277
>
> URL: http://svn.apache.org/viewvc?rev=1397277&view=rev
> Log:
> Document the way to test for nullity in an IfController
>
> Modified:
>     jmeter/trunk/xdocs/usermanual/component_reference.xml
>
> Modified: jmeter/trunk/xdocs/usermanual/component_reference.xml
> URL:
> http://svn.apache.org/viewvc/jmeter/trunk/xdocs/usermanual/component_reference.xml?rev=1397277&r1=1397276&r2=1397277&view=diff
>
> ==============================================================================
> --- jmeter/trunk/xdocs/usermanual/component_reference.xml (original)
> +++ jmeter/trunk/xdocs/usermanual/component_reference.xml Thu Oct 11
> 20:15:36 2012
> @@ -2078,6 +2078,12 @@ setting is reset when a parent Loop Cont
>                 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.
>                 </note>
> +               <note>
> +               To test a variable for nullity do the following, suppose
> var is named myVar, expression will be:
> +               <ul>
> +                <li>"${myVar}" == "\${myVar}"</li>
> +                </ul>
> +               </note>
>         </description>
>  <properties>
>      <property name="Name" required="No">Descriptive name for this
> controller that is shown in the tree.</property>
>
>
>

Re: Testing for nullity in IfController

Posted by sebb <se...@gmail.com>.
On 11 October 2012 21:18, Philippe Mouawad <pm...@apache.org> wrote:
> Hello,
> I was wondering if there isn't a better way to do this, which I don't like
> very much.

It's not really testing for null, it's testing whether the variable is
defined or not.

One could use vars.get("myVar") == null in one of the scripting
languages, but that does not seem any better to me, and has more
overhead.

For a simpler syntax one would have to create a function, e.g.
__undefined(myVar)
However one might also need __defined(myVar).

I don't personally that would be worth it; the syntax seems fine to
me, and helps re-inforce what happens when variables are not defined.

> Regards
> Philippe
> On Thu, Oct 11, 2012 at 10:15 PM, <pm...@apache.org> wrote:
>
>> Author: pmouawad
>> Date: Thu Oct 11 20:15:36 2012
>> New Revision: 1397277
>>
>> URL: http://svn.apache.org/viewvc?rev=1397277&view=rev
>> Log:
>> Document the way to test for nullity in an IfController
>>
>> Modified:
>>     jmeter/trunk/xdocs/usermanual/component_reference.xml
>>
>> Modified: jmeter/trunk/xdocs/usermanual/component_reference.xml
>> URL:
>> http://svn.apache.org/viewvc/jmeter/trunk/xdocs/usermanual/component_reference.xml?rev=1397277&r1=1397276&r2=1397277&view=diff
>>
>> ==============================================================================
>> --- jmeter/trunk/xdocs/usermanual/component_reference.xml (original)
>> +++ jmeter/trunk/xdocs/usermanual/component_reference.xml Thu Oct 11
>> 20:15:36 2012
>> @@ -2078,6 +2078,12 @@ setting is reset when a parent Loop Cont
>>                 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.
>>                 </note>
>> +               <note>
>> +               To test a variable for nullity do the following, suppose
>> var is named myVar, expression will be:
>> +               <ul>
>> +                <li>"${myVar}" == "\${myVar}"</li>
>> +                </ul>
>> +               </note>
>>         </description>
>>  <properties>
>>      <property name="Name" required="No">Descriptive name for this
>> controller that is shown in the tree.</property>
>>
>>
>>