jmeter-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Erez Naim <e...@theneura.com>
Subject Re: how to use properly vars function
Date Thu, 31 Dec 2015 18:25:55 GMT
Deepak, by saying "the standard functions", what do u mean? 

On Dec 31, 2015 20:06, Deepak Shetty <shettyd@gmail.com> wrote:
>
> Hi 
> >vars.put(timestamp_starts,"timestamp_start"); 
> This looks wrong - *usually* it should be 
> vars.put("Static Variable name",dynamic); -- i.e. the Key is a static 
> string that you use to name the variable and the value is the part that 
> changes - whereas you are using it in the other way 
>
> Also there doesnt look to be anything that needs beanshell - are you sure 
> the standard functions dont work for you ? 
>
>
>
> On Thu, Dec 31, 2015 at 8:20 AM, Erez Naim <Erez@theneura.com> wrote: 
>
> > Hello all, 
> > 
> > 
> > 
> > I am getting timestamp variable from the command line or a default one if 
> > none was delivered. 
> > 
> > 
> > 
> > I am using this chunk of code under BeanShellPostProcessor: 
> > 
> > import java.lang.*; 
> > 
> > 
> > 
> > int timestampInt=0; 
> > 
> > String timestamp=""; 
> > 
> > 
> > 
> > try{ 
> > 
> > timestamp=vars.get("timestamp_start"); 
> > 
> > timestampInt = Integer.parseInt(timestamp); 
> > 
> > timestampInt+=1; 
> > 
> > timestamp_start=Integer.toString(timestampInt); 
> > 
> > System.out.println("After incremental of the variable: " + 
> > timestamp_start); 
> > 
> > 
> > 
> > vars.put(timestamp_starts,"timestamp_start"); 
> > 
> > timestamp=vars.get("timestamp_starts"); 
> > 
> > 
> > 
> > 
> > 
> > }catch (Exception ex){ 
> > 
> >     log.warn("Error in my script", ex); 
> > 
> >     throw ex; // elsewise JMeter will "swallow" the above exception 
> > 
> > } 
> > 
> > 
> > 
> > 
> > 
> > Then I am using a while controller where stop condition is as follows: 
> > 
> > ${__javaScript("${timestamp_start}" <=  "${timestamp_end}")} 
> > 
> > 
> > 
> > However I noticed that timestamp doesn't increment and I get the same 
> > timestamp. 
> > 
> > 
> > 
> > Any idea what could be the problem? 
> > 
> > 
> > 
> > Thanks, 
> > 
> > 
> > 
> > Erez Naim  |  QA Lead  | 
> > 
> > [image: cid:image004.png@01D01E1B.5F153500] 
> > 
> > EL AL 2 Street | Herzliya 
> > mobile (+972) 50 9 555 686 | fax (408) 689.1366 | skype erez.neura 
> > 
> > 
> > 
> > website <http://www.theneura.com/>  |  blog <http://www.startupbitz.com/>

> >  |  twitter <https://twitter.com/intent/user?screen_name=theneura>  | 
map 
> > <http://goo.gl/maps/ZRkg5> 
> > 
> > 
> > 
> > 
> > 
Mime
View raw message