cancel
Showing results for 
Search instead for 
Did you mean: 

how to prioritize event

678
Regular Contributor

how to prioritize event

I have a test cases defined in excel like 

 

Datasource = Exel 

 

Column : Prerequsite

                CreateUser;EditUser

 

 

TestCase:     LoginRequest

DataSource: Prerequsite :  Create User Request, Edit User Rquest 

 

 

I have a Event like

 

If datasource Prereq contains Createuser than RUN CreateUserRequest and

If datasource prereq contains edituser than RUN EditUserRequest 

 

So, when i am running above event 1st Create User need to run then edituser should run 

 

but its both running parallel

 

How can i run one bye one like createUser then Edit User 

 

12 REPLIES 12
Lucian
Community Hero

Re: how to prioritize event

Hey, can you provide more info on this? Is the Event you're talking about a groovy script? Can you provide us the groovy script? Can you share a print screen of your project for us just to understand you better?

 

Cheers!



If my answer helped please click on the 'Accept as Solution' button.
678
Regular Contributor

Re: how to prioritize event

Well, let me put it in this way 

 

i have 3 variables storing in datasource as 

 

1) createuser 2) edituser 3) logoutuser 

 

and i have event like this: 

 

if (datasource.contains ("createuser")) {   Then here createuser validation will be execute }

 

if (datasource.contains ("edituser")) { Then here edit user validaton will be execute } 

 

if (datasource.contains ("logoutuser ")) { Then here logout validaton will be execute } 

 

 

Event : TestRunlisitner after step = datasource 

 

So, Here on my datasource 

 

If i keep only 1 variable like   -  createuser then event is executing correct 

 

but if i keep 3 varaibles like - createuser;edituser;logoutuser   

 

Then all 3 varaibles executing at the same time but my scenario is 

 

need to excute one by one like 1) createuser 2) edituser 3) logoutuser 

 

 

 

I hope this help you .. 

 

Thanks in advance 

 

msiadak
Community Hero

Re: how to prioritize event

So one thing I see is that you mentioned having a Data Source with multiple variables / columns, one for each of the tests you want to consider running. And that these tests execute when all three variables are present. Using a data-source for this may take some extra work to get it to function the way you want.

 

This sounds like an issue that might be solved with a wait/sleep command in groovy. That way, the Create User has time to process. You could build in some sort of check that waits until the Create User has a response, and then process the next steps. 




---

Click the Accept as Solution button if my answer has helped, and remember to give kudos where appropriate too!
TanyaYatskovska
Community Manager

Re: how to prioritize event

Hi @678,

 

Have @msiadak's reply helped you? 

---------
Tanya Yatskovskaya
SmartBear Community and Education Manager

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
678
Regular Contributor

Re: how to prioritize event

Yes, Tanya 

 

But still my issue not yet resolved, 

 

I need to get prioritize the functions 

 

 

 

 

Thanks

 

msiadak
Community Hero

Re: how to prioritize event

if (datasource.contains ("createuser")) {   Then here createuser validation will be execute }

 

if (datasource.contains ("edituser")) { Then here edit user validaton will be execute } 

 

if (datasource.contains ("logoutuser ")) { Then here logout validaton will be execute } 

This is the groovy script you provided. You need these three events to happen one after another, instead of roughly at the same time? The way your groovy script is, depending on how fast it goes, it is going to process all three blocks quickly. What I propose is putting in something like this:

 

sleep(100);

Using that sort of command can force the groovy script to sleep to give the individual events enough time to process. Outside of that, screenshots and/or a sample of your project may help us troubleshoot. 




---

Click the Accept as Solution button if my answer has helped, and remember to give kudos where appropriate too!
678
Regular Contributor

Re: how to prioritize event

here more information 

 

Datasource-ExcelFile 

 

TestCaseNumberFunction
TestCase1createuser;edituser
TestCase2createuser;edituser;logoutuser

 

 

 

 

 


Events : 
 

TestRunListener.afterStepcreate - Datasource-ExcelFile

 

Groovy Code: 

 

def datasource = context.expand( '${DataSource#Function}' )

 

Functions : 

 

//CreateUserFunction

 

if (datasource.contains("createuser")) {

//Some Create User Code 

 

//EditUserFunction

 

if (datasource.contains("edituser")) {

//Some Edit User Code 

}

 

 

//Logout User Function 

 

if (datasource.contains("logoutuser")) {

//Some Logout User Code 

}

 

 

I hope this help 

msiadak
Community Hero

Re: how to prioritize event

Have you tried adjusting your groovy script code to enact any sort of wait or check for the tests you are running to finish? I've mentioned it a few times but haven't heard whether or not that has worked for you. 




---

Click the Accept as Solution button if my answer has helped, and remember to give kudos where appropriate too!
678
Regular Contributor

Re: how to prioritize event

Yes, I tried keeping "sleep" but no luck

 

Is there any option that on the datasource row if more than one function on one single cell split bye ; and then execute 1 and 2 and 3rd

 

 

Thanks

New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors