cancel
Showing results for 
Search instead for 
Did you mean: 

Sharing is caring - code for groovy datasource

Community Hero

Sharing is caring - code for groovy datasource

As per @Olga_T's suggestion here is a script that generates some identification codes like X00001, X00002 and so on...

 

// Get current row
def row = testRunner.testCase.testSteps["DataSource"].currentRow

// Declare an array that will contain the id codes
def codes = []

// Generate all id codes
for (int i = 1; i < 100000; i++) {
	codes.add( String.format('X%05d', i) )
}

// Make the values reachable from the datasource
if (row < codes.size()) {
    // Return the name to data source's "File" property
    result["Code"] = codes[row]
}

Cheers!



If my answer helped please click on the 'Accept as Solution' button.
New Here?
Join us and watch the welcome video:
Top Kudoed Authors