Forum Discussion
JHunt
8 years agoCommunity Hero
For getting data from Excel you will need a library. You can search for that, one I see a lot is Apache POI. But it's not all that easy to use. An easier approach might be to save your Excel to CSV. Then you can do this:
/* example CSV:
*
* Aaronson,Aaron
* Baggins,Bilbo
* Dion,Celine */
new File('senders.csv')
.getText()
.split ('\n')
.collect { it.split(',') }
.each { String[] sender ->
context << [first: sender[1], last: sender[0]]
/* in the test step, use property expansions:
* ${first}, ${last} */
testRunner.runTestStepByName('some request step')
.with { result ->
/* you can add assertions on the test step,
* or you can do some here */
assert result.responseContext.contains(context.first)
assert result.responseContext.contains(context.last)
assert result.responseStatusCode == 201 //created
}
}