Logging test results in a loop

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
Carnivean
Newbie
Posts: 17
Joined: Fri Jun 10, 2011 8:04 am

Logging test results in a loop

Post by Carnivean » Fri Jun 10, 2011 8:56 am

Hi

I've just written my first script, and surprisingly it works really well.

The script runs through stress testing a UI application, at the start and finish of each section of the script I log the start and finish using a Timestamp, when all tests in the script are complete it loops back to the beginning and starts all over again.

Now my question, is there a way in the log file to indicate how many times each section of the script has looped through. The script can currently run in the region of 200 times.

Thanks for any help.

User avatar
JRL
Automation Wizard
Posts: 3526
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Fri Jun 10, 2011 12:12 pm

Create a variable to be a counter, then increment that variable each time the loop starts. You can write the value of the variable to the log file or include it in the name of the file.

Code: Select all

Let>Counter=0

Label>Loop
  Add>Counter,1
  //do stuff
  Writeln>Logfile,res,This is iteration number %counter%
  //do other stuff
Goto>Loop

Carnivean
Newbie
Posts: 17
Joined: Fri Jun 10, 2011 8:04 am

Post by Carnivean » Fri Jun 10, 2011 1:27 pm

Thanks for the help.

Writeln>Logfile,res,This is iteration number %counter%

Can you tell me what 'res' is for in the line above please?

Thanks

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Fri Jun 10, 2011 1:28 pm

Look in the help file (just hit F1 while on WriteLn):
WriteLn>file_name,result,line

Writes text to a text file. If the file does not exist it is created and the given line is written to it. If it does exist, the line is written to the end of the file. If the command was successful, result is set to zero. A non zero result means an error occurred.
You can get immediate help on any command just by hitting F1 while the cursor is on a command, or from the command builder.[/quote]
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts