cancel
Showing results for 
Search instead for 
Did you mean: 

How could be a good way to create a member which would be used in many test cases of a test suite?

SOLVED
Highlighted
New Contributor

How could be a good way to create a member which would be used in many test cases of a test suite?

I am just starting to use SoapUI recently. Can someone nicely help me figure out this problem? I have a method to create a member which would be used in many test cases of a test suite only. So won't be a good way to put the method in the global function I guess. 

1 ACCEPTED SOLUTION

Accepted Solutions
Community Hero

Re: How could be a good way to create a member which would be used in many test cases of a test suit

Something like @jkrolczy should do the trick. However, I would advise using a Test Suite Setup script for this. So the scenario would look like this:

 

1. Before a certain test suite is started, ReadyApi executes the Setup script (which generates the memberId and password and saves them at Test Suite level)

2. Every Test Case references that memberId and password.



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

View solution in original post

8 REPLIES 8
Community Hero

Re: How could be a good way to create a member which would be used in many test cases of a test suit

Hi @Flora,

 

What do you mean by member? Can you tell a little bit more about what you're trying to do?



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

Re: How could be a good way to create a member which would be used in many test cases of a test suit

Hi @Lucian ,

 

Thank you for your reply!

 

Sure! For example, I have a method to generate a memberID and password so that I can login using them to check some functionalities. 

 

I have a test suite which includes a few test cases and all of those cases have the same step: generate a new memebrID, pwd and login.

 

My question is that is there a better way to generate the memberID in the test suite level so that all the cases under that test suite can use the memberID? 

Contributor

Re: How could be a good way to create a member which would be used in many test cases of a test suit

You could create a test case in your TestSuitte that would generate a memberID and password.

This would be the first testcase to run in your suite.

Not sure how you are creating these new memberID and Pwd ??

 

TestSuite level : Custom Properties: create variables   i.e.  memberID and Pwd

 

Using Groovy script in this test cases you can extract these from a Response

or however you know these values

Then store them into a TestSuite: Custom Properties variables   i.e.  memberID and Pwd

 

testRunner.testCase.testSuite.project.setPropertyValue( "memberID ", <your value>);
testRunner.testCase.testSuite.project.setPropertyValue( "Pwd", <your value>);

 

Then in the following test cases where you need these values, refernce your TestSuite level

using this in the appropiate spot for your memberID  or Pwd

 

${#TestSuite#memberID}

${#TestSuite#Pwd}

 

 

JamesK
Contributor

Re: How could be a good way to create a member which would be used in many test cases of a test suit

Another suggestion also:

 

 

https://www.soapui.org/docs/functional-testing/properties/working-with-properties.html

 

2. and 3. on this page is another approach

 

 

JamesK
Community Hero

Re: How could be a good way to create a member which would be used in many test cases of a test suit

Something like @jkrolczy should do the trick. However, I would advise using a Test Suite Setup script for this. So the scenario would look like this:

 

1. Before a certain test suite is started, ReadyApi executes the Setup script (which generates the memberId and password and saves them at Test Suite level)

2. Every Test Case references that memberId and password.



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

View solution in original post

New Contributor

Re: How could be a good way to create a member which would be used in many test cases of a test suit

Hi @jkrolczy ,

 

Thank you for your reply. My concern is how could we guarantee the test case we used to generate memberID can be run firstly? I think they were run simultaneously.

New Contributor

Re: How could be a good way to create a member which would be used in many test cases of a test suit

Hi @Lucian 

 

Thanks again. I think using the test suite setup script would be the best way for this. The problem is I don't know how to do it? It'd be nice you can send me some materials/ documentation related to this to learn?

 

Thanks, heaps!

Community Hero

Re: How could be a good way to create a member which would be used in many test cases of a test suit

@Flora ,

 

If you click on your test suite then you'll have the Setup tab available. That's the place where you can put your actual code (I guess you already have some code for generating the userid and password, right?)

 

2019-04-15_11h44_27.png

 

Later edit: The print screen is from SoapUI Pro but it is the same on SoapUI Open Source. Just double click on your test suite to open the test suite window and then you'll see the Setup tab just like in the attached photo.

 



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