Mahak Malik
Mahak Malik

Reputation: 185

how to execute a particular test case n number of times in robot framework

I have 5 test cases regarding the creation of member and verification of job. I want to run those test cases like 5 or 20 times. My framework is robot and ide is pycharm, language - python.

APS Transformations Triggering
[Documentation] Triggering The APS Transformations for a Member
[Tags]  APSXform  APSXformTrigger  
Login to Platform Analytics
${GENERATED_MEMBER} =  Generate a Random Member  
APS_Transformations
Search for the Member
Search the Results and Go To  
Relogin If Needed
Verify Basic Member Homepage Details
Trigger APS Transformations
Save Member Details To Job Log File


APS Transformations Verification
[Documentation] Verifying The APS Transformations for a Member
[Tags]  APSXform  APSXformVerification  All
Login to Platform Analytics
Log To Console  Previous Run: ${verify_prev_run}
Fetch Previous Memeber Run Details    
Fetch URL And Go To  APP_LOGGER_URL
Log  APS Transformations are Successful.

I know that I can do a for loop for keywords but do not want to write all these test cases in one keyword. -Is there a git command where i can state that i want to run these tags for 20 times?

Upvotes: 0

Views: 2804

Answers (2)

FortCWB
FortCWB

Reputation: 25

There is an option repeating your destination path. Suppose you want to execute 6 times in your current path, then you can do as follows:

pybot --test "Yout test" . . . . . .

You can also put your tests inside a loop:

Example
    :FOR   ${count}  IN RANGE  6
    \    APS Transformations Triggering
    \    APS Transformations Verification

Upvotes: 0

Bryan Oakley
Bryan Oakley

Reputation: 385830

The simplest solution is to create a shell script that runs robot N times. You can specify a different output file for each, and then combine all of the results into a single file.

The following example will run robot 10 times and then generate log and report files of all of the combined results.

#!/bin/bash
outputs=()
for i in {0..10}; do
    output="output-$i.xml"
    outputs+=($output)
    robot --output $output $@
done
rebot ${outputs[@]}

Run it like this:

$ bash run_robot.sh example.robot 

Upvotes: 1

Related Questions