SmartBear Connect 2018
Join us at SmartBear Connect 2018 on October 29th & 30th in Boston, MA.
Apply to speak and share your experience with the greater SmartBear Community
Reply
Occasional Contributor

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
Regular Contributor

Re: Script assertion using testrunner

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.
Remember:Questions are more important than answers.
The answer is 42 I'm a ninja!
Occasional Contributor

Re: Script assertion using testrunner

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

Re: Script assertion using testrunner

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.