I am getting "groovy.lang.MissingPropertyException: No such property:" for my groovy script.

Originally posted by vivram on March 14, 2018

Hi

I’m using the SoapUI free version.

My groovy script below is throwing me this error “groovy.lang.MissingPropertyException: No such property: DEC for class: com.eviware.soapui.impl.wsdl.panels.support.MockTestRunner error at line: 20”

Groovy script:

def effectiveDate = new Date().format(“yyyy-MM-dd’T’03:56:29+13:00”)
log.info effectiveDate

def LastRenDate = new Date().format(“yyyy-MM-dd’T’03:56:29+13:00”)
log.info LastRenDate

def RenewalDate = new Date().plus(365).format(“yyyy-MM-dd’T’03:56:29+13:00”)
log.info RenewalDate

def ExpiryDate = new Date().plus(365).format(“yyyy-MM-dd’T’03:56:29+13:00”)
log.info ExpiryDate

def globalProperty = com.eviware.soapui.SoapUI.globalProperties.getPropertyValue(“EffectiveDate”)
log.info globalProperty

testRunner.Dec_Quote.setPropertyValue(“EffectiveDate”, effectiveDate)

I have already got this property in my test case, not sure why its throwing this error

Originally posted by avidCoder on March 15, 2018

You have problem with this line of code:-

testRunner.Dec_Quote.setPropertyValue(“EffectiveDate”, effectiveDate)

What is this “Dec_Quote”?

This is how you should set the property value:-

testRunner.testCase.testSuite.project.setPropertyValue(“yourProp”, yourValue )

Originally posted by JHunt on March 15, 2018

It says you have a problem at line 20, but the script you posted is not 20 lines long.

It says it has a problem with something called DEC in capitals, but the script you posted doesn’t contain that, so is it possible the error is in another part you haven’t posted?

Also, I see that the error is coming from MockTestRunner, which means you are running the script in isolation (without the context of the test case). That could be a problem - try running it as a complete test case.

Lastly, the error is probably in this line or a similar one:

testRunner.Dec_Quote.setPropertyValue("EffectiveDate", effectiveDate)

Did you mean the below?

testRunner.testCase.testSteps['Dec_Quote']    .setPropertyValue("EffectiveDate", effectiveDate)

Originally posted by vivram on March 15, 2018

The structure is as follows

Project: SMEPK_MV

Test Suite: Test_MV_Rates

Test Case: DEC

Test Step: Dec_Quote

My groovy script is the first test step inside the test case DEC.

I tried below

testRunner.DEC.Test_MV_Rates.SMEPK_MV.setPropertyValue(“EffectiveDate”, effectiveDate)

Still getting same error.

I created custom property ‘EffectiveDate’ for DEC test case, which I want to use for test steps within this test case. Not sure where the problem is..

Thanks

Originally posted by vivram on March 15, 2018

Thanks,

I tried running it on a complete test case, still same result

testRunner.DEC.testSteps[‘Dec_Quote’].setPropertyValue(“EffectiveDate”, effectiveDate)

DEC is the Test Case

Originally posted by vivram on March 15, 2018

Thanks all for your help.

The below worked.

testRunner.testCase.setPropertyValue(“EffectiveDate”, effectiveDate)

I was thinking we have to literally replace the test case name with the actual test case name, which isn’t the case.

All good now :slight_smile:

Originally posted by avidCoder on March 15, 2018

That’s what I replied in previous threads. You can set property value at any level of the project.

//TestCase Level

testRunner.testCase.setPropertyValue(“EffectiveDate”, effectiveDate)

//TestSuite Level

testRunner.testCase.testSuite.setPropertyValue(“EffectiveDate”, effectiveDate)

//Project Level

testRunner.testCase.testSuite.project.setPropertyValue(“EffectiveDate”, effectiveDate)