Ask a Question

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

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

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 

 

groovyguy
Champion Level 0

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
SmartBear Alumni (Retired)

Hi @678,

 

Have @groovyguy's reply helped you? 

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



678
Regular Contributor

Yes, Tanya 

 

But still my issue not yet resolved, 

 

I need to get prioritize the functions 

 

 

 

 

Thanks

 

groovyguy
Champion Level 0

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

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 

groovyguy
Champion Level 0

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

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

cancel
Showing results for 
Search instead for 
Did you mean: