Forum Discussion

Department_of_T's avatar
Department_of_T
Contributor
12 years ago

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?
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" )

3 Replies

  • Hi, i have tried the built in reports and they make it very difficult to debug since we run one testcase hundreds of times in a datasource loop and only need to know which teststeps fail BUT when they fail we need to know which row number (iteration) the datasource was on. If i could write to the SOAPUI TestCase Log then this would help but i have read that this file is not writeable .

    Do you have a groovy script (or can help me edit my current script) so i can have a text report that details which datapool iteration a test step fails on?
  • Just a suggestion: couldn't you append the information you're missing inside the loop? Something like this (can't test it right now, so excuse me if there are errors):

    //Log Failures
    f = new File( folderName + '/' +time()+" "+ testsuitename + ' -- '+ failCount+' Failure(s).txt')
    for(int row = 1; row <= testRunner.results; row++ ){
    totalCount++
    if (r.getStatus().toString() == 'FAILED'){
    f.append("Failure on row $row")
    failCount++
    }
    }
    f.append( failCount + " test step(s) failed out of a total of "+totalCount+ " test steps executed" )

    Kind regards,
    Manne, SoapUI Developer