Check Out the Latest News About SmartBear Connect
JOIN OUR WEEKLY CHALLENGE
API_Bloom_banner

API Bloom is a weekly prize-winning challenge in the Ready! API Community. Each week, we assign a task that you need to accomplish to become a winner. See the rules here.

THIS WEEK TASK
Give the biggest number of Solutions on the Ready! API forums
Top 3 contributors will get $50, $35, and $15 gift cards!

WEEK 1-12 WINNERS
@nmrao, @msiadak, @Debz, @richie, @Emil91, @PramodYadav, @jkrier, @sanj, @mbheeke, @Radford, @kmaster, @kbw

Reply
Highlighted
New Contributor
Posts: 2
Registered: ‎06-19-2017
Accepted Solution

Property Transfer Question

Hello,

 I have a TestCase where I need to generate x number of unique strings. Let's say 10 email addresses. The way I am doing things now is I have 10 groovy script test steps that randomly create the email string and 10 Transfers. Is there a way to condense this? If I have one groovy script that generates the random string can I just evaluate it each time I do a property transfer? I have 6 other strings I need to generate as well (FirstName, LastName, etc...) so the way I am currently doing things I would have 70 test steps just for generating data. 

Thanks!

Community Leader
Posts: 358
Registered: ‎06-22-2015

Re: Property Transfer Question

I typically create a properties step and use a groovy script to write my properties to that with a groovy test step. If I need multiple of the same value per request, I name them differently.

 

Example:

CustomerEmail

ManagerEmail

etc.

 

If I need multiple data-sets for multiple requests, I'd have:

CustomerEmail1

ManagerEmail1

CustomerEmail2

ManagerEmail2

 

 

Then in my groovy script I have a for-loop that iterates through how many data-sets I need, and generates how many elements I need per dataset.

 

Here's a very quick groovy script example. 

 

 

def propertiesStep = testCase.testSteps["Properties"];

def generateEmail()
{
     // insert email generation script here
} for(int i = 1; i < 100; i++) { propertiesStep.setPropertyValue("CustomerEmail" + i, generateEmail()); propertiesStep.setPropertyValue("ManagerEmail" + i, generateEmail());
i++; }

 

Community Hero
Posts: 4,598
Registered: ‎05-17-2013

Re: Property Transfer Question

Why to even have property transfer step again? Just wouldn't it be suffice to use test case properties and use property expansion?
New Contributor
Posts: 2
Registered: ‎06-19-2017

Re: Property Transfer Question

This seems like a good idea. I will try it, thanks!

Community Leader
Posts: 358
Registered: ‎06-22-2015

Re: Property Transfer Question

@zkerbo: Thanks for the kudos! Let me know if you run into any more issues with it! I hope it works Smiley Very Happy 

Let's Meet in Boston
Join the user conference on Sep 12-13