cancel
Showing results for 
Search instead for 
Did you mean: 

Running a branch in parallel

SOLVED
Highlighted
New Contributor

Running a branch in parallel

Hello,

 

Obligatory "first post here, so please be gentle."

 

I'm attempting to run two test cases in parallel but only after a specific test step has been run in my first test case. The APIs I'm testing require a dynamic authorization token in the header that changes every 60 seconds after a specific API request has been sent. Presently I have a groovy script in the first test case to run a groovy script in second test case that contains a while loop to continuously run the second test case while the first test case is running (there is a groovy script at the end of TestCase1 to set the 'running' property to 'false' to stop the loop). However, the first test case comes to a halt as it waits on the second test case's loop instead of branching to start the second test case in parallel while continuing with the first. 

 

Is it possible to accomplish this task within the confines of the program? 

 

Test case 1's script: 

def hello = testRunner.testCase.testSuite.project.getTestSuiteByName('BaseClientPortalTesting').getTestCaseByName('HeartbeatFlow').getTestStepByName('startLoop')

hello.run(testRunner, context);

Test case 2's script

def thread = Thread.start{

def running = context.expand('${#TestSuite#RUNNING}').asBoolean();
def runTimes = 0; while (running){ runTimes++; log.info(runTimes);

running = context.expand('${#TestSuite#RUNNING}').asBoolean();
testRunner.runTestStepByName("Heartbeat");
def Response = context.expand('${Heartbeat#Response}'); if (Response != "true"){ testRunner.runTestStepByName("RefreshToken"); sleep (1000); testRunner.runTestStepByName("TransferRefreshedToken"); } else { sleep (60000); } } } thread.join();

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Hero

Re: Running a branch in parallel

@wpar,
This is how it can achieved if the objective is to fire the request x no of times with a delay of y seconds which uses out of the box functionality.
Have simple test case with required test step (no scripts involved), create a load test as described in the below documentation and execute it (either from the tool or from the command line, I prefer the later to execute).
https://support.smartbear.com/readyapi/docs/loadui/tutorial/your-first-test/creating-load-test.html

Please see if this approach is suitable for your case.


Regards,
Rao.

View solution in original post

3 REPLIES 3
Highlighted
Community Hero

Re: Running a branch in parallel

@wpar,
This is how it can achieved if the objective is to fire the request x no of times with a delay of y seconds which uses out of the box functionality.
Have simple test case with required test step (no scripts involved), create a load test as described in the below documentation and execute it (either from the tool or from the command line, I prefer the later to execute).
https://support.smartbear.com/readyapi/docs/loadui/tutorial/your-first-test/creating-load-test.html

Please see if this approach is suitable for your case.


Regards,
Rao.

View solution in original post

Highlighted
Community Manager

Re: Running a branch in parallel

Great advice nmrao!

 

@wpar did the suggestion work? 


Sonya Mihaljova
Community and Education Specialist

Learn SmartBear products in a fun and easy way and prove your knowledge!
>>Participate in the TechCorner Challenge today
Highlighted
New Contributor

Re: Running a branch in parallel

So from the looks of it this isn't the exact route I was attempting to go (though that could just be because I'm so new to the program), but it did make me realize another way to write the test cases that would allow me to use the method you mention.

 

So thank you! 

New Here?
Join us and watch the welcome video:
Announcements
TechCorner Leaderboard
Compete with community members in the TechCorner Challenge and get into the Leaderboard!

Rank Participant Points Earned
1 msiadak 12
2 nmrao 8
3 HimanshuTayal 3
Top Kudoed Authors