Ask a Question

Clone Datasource using groovy script

SOLVED
shrik18
Occasional Contributor

Clone Datasource using groovy script

I have a datasource using internal datagen and another datasource using groovy. I want to trasnfer complete datasource 1 to datasource 2. Baiscally make a copy. How can I achieve this using groovy?

9 REPLIES 9
groovyguy
Champion Level 0

When you say you want to copy datasource 1 to datasource 2, what do you mean?

 

Do you want to replace DataSource 2 with data source 1?

Or do you want to copy the properties from Data Source 1 to Data Source 2? 

Or do you want to make a brand new copy of Data Source 1?




---

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

Datasource 2 is groovy script. What I am trying to do is create dynamic datasource. Depending on condition Datasource will have all the values from Datasource 1 or Datasource 3.

Bear with me, I am still trying to understand what you are trying to do.


DataSource1 : Internal Datagen.

DataSource2: Dynamic datasource

DataSource3: Groovy datasource

 

Based on a condition, you want to alter DataSource 2 to either be DataSource 1 or DataSource 3? Is that the use case you are trying to figure out?




---

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

@groovyguyThanks for your prompt replies.  Let me make it simple, Use case is 

Datasource1: using datagen multiple properties multiple rows
Datasource2: using datagen mulitple properties multiple rows
Datasource3:  using groovy. This one will be dynamic and condition will be inside this datasource

For example : Datasource 3 with groovy will look like 
if(x = 1)
Datasource 3 = Datasource 1 
else 
Datasource 3 = Datasource 2

I think what you want is possible, but not in the way you want. For the groovy script datasource, you could likely copy properties from either of the other two datasource based on a condition, but this will get complex really quickly if DataSource1 and DataSource2 have varying different properties.

 

What about the following:

  1. DataSource1 (DataGen)
  2. DataSource2 (DataGen)
  3. Groovy Script test step:
    1. Condition to decide which DataSource to use
    2. Based on condition, it will copy the setup of either DataSource1 or DataSource2 to DataSource3
  4. DataSource3 (DataGen)

 

 

Using a DataSource - Groovy test in DataSource3 would require you to basically completely code out the datagen steps you want to use from DataSource 1 or 2, or how to get data from them. The way I present would re-use the same. Does that sound feasible? 

 




---

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

the properties are same in all three so that is not the problem. The values and number of rows changes.  What you are suggesting is also feasible, just need datasource to reflect src 1 or src 2. 

shrik18
Occasional Contributor

@groovyguy : please can you assist with the groovy script for your suggestion. I want to copy whole data source and I am not able to iterate through rows. 

I'll see if I can work out a groovy script to do this. It may take a bit.




---

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

Hi,

I found a work around for this. I used groovy script to set data in property step. Added a property "rows" in property step which would determine the number of rows in datasource. Used this propery in number of rows field of datasource. This let me manipulate the datasource upto some extent.

cancel
Showing results for 
Search instead for 
Did you mean: