Forum Discussion

678's avatar
678
Regular Contributor
6 years ago

Error while getting testcases status from all testsuites on project level

i placed below script on Project - Teardown but its giving below error 

 

Note: If i place below script on TestSuite level - working fine but not working on project level 

 

ERROR [errorlog] com.eviware.soapui.support.scripting.ScriptException: Error in TearDown Script of APIAutomation
com.eviware.soapui.support.scripting.ScriptException: Error in TearDown Script of APIAutomation
at com.eviware.soapui.impl.wsdl.WsdlProject.runAfterRunScript(WsdlProject.java:2739) ~[ready-api-soapui-2.6.0.jar:2.6.0]
at com.eviware.soapui.impl.wsdl.testcase.WsdlProjectRunner.internalFinally(WsdlProjectRunner.java:186) [ready-api-soapui-2.6.0.jar:2.6.0]
at com.eviware.soapui.impl.wsdl.testcase.WsdlProjectRunner.internalFinally(WsdlProjectRunner.java:1) [ready-api-soapui-2.6.0.jar:2.6.0]
at com.eviware.soapui.impl.wsdl.support.AbstractTestRunner.run(AbstractTestRunner.java:154) [ready-api-soapui-2.6.0.jar:2.6.0]
at com.eviware.soapui.impl.wsdl.support.AbstractTestRunner.start(AbstractTestRunner.java:73) [ready-api-soapui-2.6.0.jar:2.6.0]
at com.eviware.soapui.impl.wsdl.WsdlProject.run(WsdlProject.java:2761) [ready-api-soapui-2.6.0.jar:2.6.0]
at com.eviware.soapui.impl.wsdl.WsdlProjectPro.run(WsdlProjectPro.java:1208) [ready-api-soapui-pro-2.6.0.jar:2.6.0]
at com.eviware.soapui.impl.wsdl.WsdlProjectPro.run(WsdlProjectPro.java:1203) [ready-api-soapui-pro-2.6.0.jar:2.6.0]
at com.smartbear.ready.cmd.runner.SoapUITestCaseRunner.runProject(SoapUITestCaseRunner.java:599) [ready-api-runners-2.6.0.jar:?]
at com.smartbear.ready.cmd.runner.pro.SoapUIProTestCaseRunner.runProject(SoapUIProTestCaseRunner.java:301) [ready-api-runners-2.6.0.jar:?]
at com.smartbear.ready.cmd.runner.SoapUITestCaseRunner.runRunner(SoapUITestCaseRunner.java:500) [ready-api-runners-2.6.0.jar:?]
at com.smartbear.ready.cmd.runner.pro.SoapUIProTestCaseRunner.runRunner(SoapUIProTestCaseRunner.java:111) [ready-api-runners-2.6.0.jar:?]
at com.smartbear.ready.cmd.runner.AbstractSoapUIRunner.run(AbstractSoapUIRunner.java:293) [ready-api-runners-2.6.0.jar:?]
at com.smartbear.ready.cmd.runner.AbstractSoapUIRunner.runFromCommandLine(AbstractSoapUIRunner.java:174) [ready-api-runners-2.6.0.jar:?]
at com.smartbear.ready.cmd.runner.pro.SoapUIProTestCaseRunner.init(SoapUIProTestCaseRunner.java:88) [ready-api-runners-2.6.0.jar:?]
at com.smartbear.ready.cmd.runner.pro.SoapUIProTestCaseRunner.main(SoapUIProTestCaseRunner.java:84) [ready-api-runners-2.6.0.jar:?]
Caused by: groovy.lang.MissingPropertyException: No such property: testSuite for class: Script1
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:53) ~[groovy-all-2.4.4.jar:2.4.4]
at org.codehaus.groovy.runtime.callsite.PogoGetPropertySite.getProperty(PogoGetPropertySite.java:52) ~[groovy-all-2.4.4.jar:2.4.4]
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGroovyObjectGetProperty(AbstractCallSite.java:307) ~[groovy-all-2.4.4.jar:2.4.4]

 

 

script : 

import com.eviware.soapui.model.testsuite.TestStepResult.TestStepStatus
import com.eviware.soapui.model.testsuite.TestRunner.Status 
import com.eviware.soapui.impl.wsdl.*
import com.eviware.soapui.impl.wsdl.testcase.*
import com.eviware.soapui.model.testsuite.*

def testCaseMap = [:]
def testCaseStatusMap = [:]
testSuite.testCaseList.each{

def reportMap=[:]
it.testSteps.each{

def testCaseStatus =true
try{

reportMap << [(it.value.name):(it.value.getAssertionStatus().toString())]
tempStatus = (it.value.getAssertionStatus().toString()=='PASS')?true:false
testCaseStatus = testCaseStatus && tempStatus

testSuite.setPropertyValue("Status", testCaseStatus.toString())
}

catch (e){

//log.info e

}

}

testCaseStatus = testSuite.getPropertyValue("Status")
def testCaseStatusStr = (testCaseStatus=='true')?'PASS': 'FAIL'

testCaseStatusMap << [(it.name):(testCaseStatusStr.toString())]
}