Forum Discussion

TraceyK's avatar
TraceyK
Occasional Contributor
13 years ago

[Res] Use event listener with Groovy script to run test case

Hi,

I'm using an event listener to run a Groovy script that runs a test case.
import com.eviware.soapui.model.testsuite.TestRunner.Status
import com.eviware.soapui.impl.wsdl.testcase.WsdlTestCaseRunner
log.info("============Get Properties for Report================= ")
def testStatus = false
def propsTest = testRunner.testCase.testSuite.project.testSuites["Phoenix REST API Test Suite"].testCases["GetPropertiesForReport"]
def runner = propsTest.run(new com.eviware.soapui.support.types.StringToObjectMap(), false)

The event listener is TestSuiteRunListener.beforeRun.

When I launch TestRunner (through the soapUI UI) I get the following in the log:

14:55:17,153 INFO [log] ============Get Properties for Report=================
14:55:17,168 ERROR [EventHandlersRequestFilter] groovy.lang.MissingPropertyException: No such property: testCase for class: com.eviware.soapui.impl.wsdl.testcase.WsdlTestSuiteRunner
14:55:17,177 ERROR [SoapUI] An error occured [No such property: testCase for class: com.eviware.soapui.impl.wsdl.testcase.WsdlTestSuiteRunner], see error log for details

The error references the line def propsTest = testRunner.testCase.testSuite.project.testSuites["Phoenix REST API Test Suite"].testCases["GetPropertiesForReport"].

What have I missed?
Thank you,
TraceyK

2 Replies

  • Hi!

    What you missed is that testRunner is a WsdlTestSuiteRunner (http://www.soapui.org/apidocs/com/eviwa ... l/testcase) so by changing:

    def propsTest = testRunner.testCase.testSuite.project.testSuites["Phoenix REST API Test Suite"].testCases["GetPropertiesForReport"]

    to
    def propsTest = testRunner.testSuite.project.testSuites["Phoenix REST API Test Suite"].testCases["GetPropertiesForReport"]


    it should work.

    Hope this helps!

    --
    Regards

    Erik
    SmartBear Sweden