cancel
Showing results for 
Search instead for 
Did you mean: 

Script assertion using testrunner

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
3 REPLIES
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.

 

Watch a new Video
Top Kudoed Authors