Usha_Kodali
14 years agoFrequent Contributor
how to access testRunner from the TearDown of TestSuite?
Hi,
I want to have the test step results printed for each test case by writing groovy script in the TearDown script of TestSuite.
Can you let me know how to access testRunner.results from the teardown script of TestSuite?
I tried following script but it complaints saying testRunner not found
import com.eviware.soapui.impl.support.http.HttpRequestTestStep
def testsuitename = testSuite.name
log.info(testsuitename)
for(testCase in testSuite.testCaseList)
{
if(!testCase.isDisabled())
{
log.info(testCase.name)
def logfilepath = "C:/Automation/Soapui/Shows/Log/"
def d1 = new File("${logfilepath}/${testsuitename}")
d1.mkdir()
logFile = new File("${d1}/${testCase.name}.log")
if(logFile.exists())
{
logFile.delete();
}
def today= new Date()
bufferedWriter = new BufferedWriter(new FileWriter("${d1}/${testCase.name}.log"));
bufferedWriter.writeLine "Run time:"
bufferedWriter.writeLine today.toString()
bufferedWriter.writeLine "Test case: $testCase.name"
bufferedWriter.writeLine("Test result count: ${testSuite.getTestCaseAt(4).getTestStepAt(1).testRunner.results.size()}")
def int i = 1
testRunner.results.each { testResult ->
String testStepName = testResult.testStep.name
bufferedWriter.writeLine "Test step $i '$testStepName'"
bufferedWriter.writeLine "Test step $i result: status $testResult.status, size $testResult.messages, messages: $testResult.messages"
++i
}
bufferedWriter.flush();
bufferedWriter.close();
}
}
I want to have the test step results printed for each test case by writing groovy script in the TearDown script of TestSuite.
Can you let me know how to access testRunner.results from the teardown script of TestSuite?
I tried following script but it complaints saying testRunner not found
import com.eviware.soapui.impl.support.http.HttpRequestTestStep
def testsuitename = testSuite.name
log.info(testsuitename)
for(testCase in testSuite.testCaseList)
{
if(!testCase.isDisabled())
{
log.info(testCase.name)
def logfilepath = "C:/Automation/Soapui/Shows/Log/"
def d1 = new File("${logfilepath}/${testsuitename}")
d1.mkdir()
logFile = new File("${d1}/${testCase.name}.log")
if(logFile.exists())
{
logFile.delete();
}
def today= new Date()
bufferedWriter = new BufferedWriter(new FileWriter("${d1}/${testCase.name}.log"));
bufferedWriter.writeLine "Run time:"
bufferedWriter.writeLine today.toString()
bufferedWriter.writeLine "Test case: $testCase.name"
bufferedWriter.writeLine("Test result count: ${testSuite.getTestCaseAt(4).getTestStepAt(1).testRunner.results.size()}")
def int i = 1
testRunner.results.each { testResult ->
String testStepName = testResult.testStep.name
bufferedWriter.writeLine "Test step $i '$testStepName'"
bufferedWriter.writeLine "Test step $i result: status $testResult.status, size $testResult.messages, messages: $testResult.messages"
++i
}
bufferedWriter.flush();
bufferedWriter.close();
}
}