Department_of_T
12 years agoContributor
test step logging
I have a testcase that pulls about 70 records for a excel sheet (datasource) which means the test case is looped 70 times. I would like to log a small summary report of the failed teststeps corresponding to the row in the datasource. I grab the row (input) variable from the row in the Datasource and use a property transfer to store the value in the Test Suite custom property.
eg if the test ran 70 times and the "createPersonDriverLicenceApplication - Request 1" failed at row 5, 10, 20 and 50 then i would like a log to be displayed similar to the below format.
FAILURES:
<step name> - Row <failure row>
X test step(s) failed out of a total of X test steps executed
FAILURES:
createPersonDriverLicenceApplication - Request 1 - Row 5
createPersonDriverLicenceApplication - Request 1 - Row 10
createPersonDriverLicenceApplication - Request 1 - Row 20
createPersonDriverLicenceApplication - Request 1 - Row 50
4 test step(s) failed out of a total of 95 test steps executed
I have placed this script in the TearDown script but i am having trouble getting the individual rows. Can anyone help?
another version
eg if the test ran 70 times and the "createPersonDriverLicenceApplication - Request 1" failed at row 5, 10, 20 and 50 then i would like a log to be displayed similar to the below format.
FAILURES:
<step name> - Row <failure row>
X test step(s) failed out of a total of X test steps executed
FAILURES:
createPersonDriverLicenceApplication - Request 1 - Row 5
createPersonDriverLicenceApplication - Request 1 - Row 10
createPersonDriverLicenceApplication - Request 1 - Row 20
createPersonDriverLicenceApplication - Request 1 - Row 50
4 test step(s) failed out of a total of 95 test steps executed
I have placed this script in the TearDown script but i am having trouble getting the individual rows. Can anyone help?
def testsuiteLongName=testRunner.testCase.testSuite.name
def testcaseLongName=testRunner.testCase.name
def testsuitename = testsuiteLongName.replace("TestSuite: ", "")
def testcasename = testcaseLongName.replace("TestCase: ", "")
def testSuiteInput = testRunner.testCase.testSuite.getPropertyValue( "input" )
groovyUtils = new com.eviware.soapui.support.GroovyUtils( context )
def time() {
date = new Date()
dateFormat = new java.text.SimpleDateFormat('HH-mm')
shortDateName = dateFormat.format(date)
return shortDateName
}
def date() {
date = new Date()
dateFormat = new java.text.SimpleDateFormat('ddMMyyyy')
shortDateName = dateFormat.format(date)
return shortDateName
}
def folderName = "C:/SoapOutput/" + date()
new File(folderName).mkdirs()
def failCount = 0
def totalCount = 0
def results = testRunner.results
//Log Failures
for( r in testRunner.results ){
totalCount++
if (r.getStatus().toString() == 'FAILED'){
failCount++
}
}
f = new File( folderName + '/' +time()+" "+ testsuitename + ' -- '+ failCount+' Failure(s).txt')
f.append( failCount + " test step(s) failed out of a total of "+totalCount+ " test steps executed" )
another version
def testsuiteLongName=testRunner.testCase.testSuite.name
def testcaseLongName=testRunner.testCase.name
def testsuitename = testsuiteLongName.replace("TestSuite: ", "")
def testcasename = testcaseLongName.replace("TestCase: ", "")
def testSuiteInput = testRunner.testCase.testSuite.getPropertyValue( "input" )
groovyUtils = new com.eviware.soapui.support.GroovyUtils( context )
def time() {
date = new Date()
dateFormat = new java.text.SimpleDateFormat('HH-mm')
shortDateName = dateFormat.format(date)
return shortDateName
}
def date() {
date = new Date()
dateFormat = new java.text.SimpleDateFormat('ddMMyyyy')
shortDateName = dateFormat.format(date)
return shortDateName
}
def folderName = "C:/SoapOutput/" + date()
new File(folderName).mkdirs()
def failCount = 0
def totalCount = 0
def results = testRunner.results
//Log Failures
for( r in testRunner.results ){
totalCount++
def input=testRunner.testCase.testSuite.getPropertyValue("input")
if (r.getStatus().toString() == 'FAILED'){
failCount++
}
}
f = new File( folderName + '/' +time()+" "+ testsuitename + ' -- '+ failCount+' Failure(s).txt')
f.append( failCount + " test step(s) failed out of a total of "+totalCount+ " test steps executed" )