Forum Discussion
Hey Sanj,
It is a good approach, though I prefer to use a database to do the same thing. but yeah, if you start clean, you build up a good dynamic foundation. There is just no point of building crap and building more crap on top of it. It will just fall apart one day haha.
- sanj7 years agoSuper Contributor
I would prefer DB also but at our company its pretty hard to get DBs going which is why I am stuck using an approach such as Excel
Conceptuually they both lead to the same results
Here is example of groovy code I use
// 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 casedef 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} ----------------")
Related Content
- 4 years ago
- 6 years ago
Recent Discussions
- 5 days ago
- 10 days ago