You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jmeter.apache.org by Remedy QA <re...@yahoo.com> on 2004/06/05 02:53:45 UTC

Re: While loop functionality

I tried with the June 3rd nightly build and this workaround for a while
loop isn't quite working.

There are two problems:

1.  Using the Test Action sampler doesn't execute the IF condition at
all--only when I put a "real" sampler like an HTTP Request sampler.

2.  The IF condition only evaluates once.  When the loop executes a
second time, the IF condition doesn't seem to evaluate at all and
therefore, the loop ends.  I made sure the IF condition should evaluate
by setting the condition to 1 == 1. I read in previous messages that
other users have seen similiar behavior but no resolution was given. I
tried searching through bugzilla for such a bug but didn't see one.

Has anyone tried this while loop workaround? 
For the User Parameters, should the Update Once Per Iteration be
unchecked?  

thanks,
mabel
--------------------------------------------------------------------------------

From: Thad Smith 
Subject: Re: While loop functionality 
Date: Thu, 29 Apr 2004 12:23:30 -0700 

--------------------------------------------------------------------------------
Actually there is a way to do this.

I've made some modifications to the ForLoop controller
to allow it to use a JMeter variable as a loop
counter. What you do is initialize a JMeter variable
to 1...and use that JMeter variable as the loop
counter. If you want to loop again then increment the
counter variable and you'll loop again.

Your test tree would look something like:

Test Plan

      |

     Thread Group

         |

        MatchTest

          |

         User Parameters
           i=1

         /pages/login.jsp

         /pages/j_security_check

        /pages/main.do

        /pages/top.jsp

        /pages/test.tst

         LoopController 
           Loop Count: ${i}

           |
 
           /pages/taskList.do

               |

               Regular Expression Extractor
                 Reference Name: done
                 Regular Expression: Done
                 Template: true
                 Match No: 1
                 Default Value: false

           If Controller
             Condition: !${done}

                |

                User Parameters
                   i=${__javaScript(${i}+1,)}

                Test Action
                   Target: Current Thread
                   Action: Pause
                   Duration: 0

       /pages/logout.do

Basically, what's happening here is that you are going
to execute the /pages/taskList.do http request at
least once. If the text Done is found than the JMeter
varible ${done} is set to true, else false. The If
Controller is a child of the Loop Controller and
increments the value of ${i} if !${done} is true (the
text "Done" wasn't found). You have to stick the Test
Action in the if controller because the controller
won't execute at all if it doesn't have a sampler to
sample. 

Test Action is a new Sampler that I added a few weeks
ago that will either pause or stop the current thread
or the entire test based on how you set it up. It's a
sampler because that was the only way to introduce
this functionality without completely rewriting
JMeter. Plus, I think it's pretty convenient for use
in the above scenario...It basically pauses the test
for 0 milliseconds. The Test Action sampler doesn't
actually return a sample. You can use any other
sampler in its place for that matter.

Note: The above scenario only works with the current
code in the nightly build.

Regards,

Thad Smith

P.S. There has been talk of creating some eclipse
plugins that allows you to run JMeter inside of a Java
program in eclipse, but nothing has been done yet.

--- Hans Then <[EMAIL PROTECTED]> wrote:
> Jordi Salvat i Alabart wrote:
> 
> > Not currently.
> >
> > Jacqui Guerrero wrote:
> >
> >> Is there a way to simulate a while loop in the
> test plan?  
> >
> More generally, is there a way to create the test
> plan in a programming 
> language? Is it possible to call the Java objects
> that execute the test 
> plan directly from a Java program. The functionality
> I am looking for is 
> somewhat like HttpUnit, but with the focus on
> load-testing, so I also 
> need the stress-engine and the reporting facilities.
> This would make 
> simulating complex user interactions less difficult
> than it is using 
> only a GUI.
> 
> Hans Then
 



	
		
__________________________________
Do you Yahoo!?
Friends.  Fun.  Try the all-new Yahoo! Messenger.
http://messenger.yahoo.com/ 

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org