Forum Discussion

DDimanlig's avatar
DDimanlig
Occasional Contributor
11 years ago

Script assertion using testrunner

I've read a few posts regarding the use of script assertions with the testrunner. I thought the below command to get a property value would work:

def expected = testRunner.testCase.getPropertyValue("suiteNumber")


However, I get this error when I use the testrunner: [No such property: testRunner for class: Script1]

Do I need a particular import? I've tried the following imports:

import com.eviware.soapui.model.testsuite.TestRunner.*
import com.eviware.soapui.model.testsuite.*
import com.eviware.soapui.model.*

I'm currently using SoapUI Pro 4.6.4

3 Replies

  • PaulDonny's avatar
    PaulDonny
    Regular Contributor
    Script Assertion does not have access to the testRunner, you have to use the messageExchange instead.


    def testCase = messageExchange.modelItem.testCase;
    def expected = testCase.getPropertyValue("suiteNumber");



    This should work.
    • sathyarajg's avatar
      sathyarajg
      Occasional Contributor

      may i know the root cause why this is not access to the test runner?


      PaulDonny wrote:
      Script Assertion does not have access to the testRunner, you have to use the messageExchange instead.


      def testCase = messageExchange.modelItem.testCase;
      def expected = testCase.getPropertyValue("suiteNumber");



      This should work.

      PaulDonny wrote:
      Script Assertion does not have access to the testRunner, you have to use the messageExchange instead.


      def testCase = messageExchange.modelItem.testCase;
      def expected = testCase.getPropertyValue("suiteNumber");



      This should work.

       

  • DDimanlig's avatar
    DDimanlig
    Occasional Contributor
    Thanks! I though the testrunner syntax was needed if the test was being invoked using testrunner.sh. It's working now.