Forum Discussion

vivram's avatar
vivram
Occasional Contributor
7 years ago

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

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

 

 

 

  • avidCoder's avatar
    avidCoder
    Super Contributor

    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 )

    • vivram's avatar
      vivram
      Occasional Contributor

       

      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

       

       

  • JHunt's avatar
    JHunt
    Community Hero

    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)

     

     

    • vivram's avatar
      vivram
      Occasional Contributor

      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

  • vivram's avatar
    vivram
    Occasional Contributor

    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 :)

    • avidCoder's avatar
      avidCoder
      Super Contributor

      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)