Testing approach Business logic - Scenarios as TCs in Excel Use Groovy to run these TCs
I think Ihave read some very inspiring threads and that gave a motivation to reflect on how I ave changed the testing approach where I work
So before I came:
We had throusands of tests cases and guess what, only thing or things would a very params in the requets
So I said this is bloody in efficient and not cool!
I have strong dev background in java and already used apache POI in my previous life to create excel spreadsheets.
So here is what I did:
I have all my test data which is referenced by test case ID
I am basically using groovy to read from this spreadsheet and run the templated test step.
Properties in excel are mapped on to test suite properties and these properities are expanded onto the requests.
So before it would take days to do TCs.
Now it takes minutes
Rest of of time is spent hitting the gym or having a coffeee lol
Not really Now they got me doing other stuff. for eg now I ma interested in service virtualization.
But the point is spent time up front and do things right!
Here is example of groovy code I use (added here from the reply below by a moderator)
// Declare content to be tested
import com.google.common.html.HtmlEscapers
import com.soapuitests.*
def tempExelParser = new ExcelParser()
String path = "U:\\git\\ens-automated-tests\\odm-content.xls"
String excelSheet = "test-24hr"
tempExelParser.readXLSFile(path,false,excelSheet)
String key = "test-PNR"
String value = "test-yyc-cashlessjun"
def tempMap = tempExelParser.getData(key,value)
log.info("starting tests: ${value} ----------------")
log.info("data map : ${tempMap}")
//def contentMap = tempMap
// initialize props with blanlk values
// now set with new values form excel
// set test case content
def prop = testRunner.testCase.testSuite.propertyList
log.info("value : ${prop}")
def propArr = testRunner.testCase.testSuite.getProperties()
for ( item in propArr ) {
testRunner.testCase.testSuite.setPropertyValue(item.key, "")
log.info("value : ${item.key} ${item.value}")
}
for ( item in tempMap) {
testRunner.testCase.testSuite.setPropertyValue(item.key, item.value)
log.info("value : ${item.key} ${item.value}")
}
// run test case
def project = testRunner.testCase.testSuite.project
def testsuite= testRunner.testCase.testSuite
tc = testsuite.getTestCaseByName("Templates")
def testStep = tc.testSteps['24hr Test Template']
//def testStep = testRunner.testCase.testSteps['24HRRequestTest']
def status = testRunner.status
log.info("status : ${status}")
def result= testStep.run(testRunner,context).getStatus().toString()
log.info("test case result : ${result}")
// get response
def currentTestStep = context.testCase.getTestStepAt(context.currentStepIndex)
String propertySpec = '${' + testStep.name + '#Response}'
assert result == "OK" : testStep.name + " ${value} Failed"
log.info("ending tests: ${value} ----------------")