Forum Discussion

NLange's avatar
NLange
Occasional Contributor
13 years ago

[Res] Need help creating/updating properties from teardown..

I am trying to create properties from the results of the tear down script. Currently i am using this script to validate all the testStep and it logs in the script log. I also want to move the same data into properties.

for( r in testRunner.results )
log.info "TestStep [" + r.testStep.name + "] " + r.status


However when i try to do
for( r in testRunner.results )
testRunner.testCase.setPropertyValue(r.testStep.name, r.status)
log.info "TestStep [" + r.testStep.name + "] " + r.status


It does not populate the properties with data. I get the error "groovy.lang.MissingPropertyException: No such property: r for class: Script1". Am i doing something wrong with the syntax?
  • Hi,

    yes.. it looks like you need to surround the statements with curly braces, ie

    for( r in testRunner.results )
    {
    testRunner.testCase.setPropertyValue(r.testStep.name, r.status)
    log.info "TestStep [" + r.testStep.name + "] " + r.status
    }

    regards,

    /Ole
    SmartBear Software
  • NLange's avatar
    NLange
    Occasional Contributor
    Thank you for the reply Ole,

    I have used added the curly brackets however it will not write r.status into the properties. It seems every time i use r.status other than log.info it breaks the script.

    When I substitute a fix value for r.status it will write into the properties.

    for( r in testRunner.results )
    {
    testRunner.testCase.setPropertyValue(r.testStep.name, "5");
    log.info "TestStep [" + r.testStep.name + "] " + r.status;
    }


    Can you assist further. I can provide my sample test case if you need.
  • What do you means with "breaks the script"?
    Do you get an error message? If so, what does it say?

    --
    Regards

    Erik
    SmartBear Sweden
  • NLange's avatar
    NLange
    Occasional Contributor
    When i perform this script in tear down:

    for( r in testRunner.results )
    {
    testRunner.testCase.setPropertyValue(r.testStep.name, r.status);
    log.info "TestStep [" + r.testStep.name + "] " + r.status;
    }


    I get the following in the error log:


    Fri Oct 19 09:07:35 PDT 2012:ERROR:groovy.lang.MissingMethodException: No signature of method: com.eviware.soapui.impl.wsdl.WsdlTestCasePro.setPropertyValue() is applicable for argument types: (java.lang.String, com.eviware.soapui.model.testsuite.TestStepResult$TestStepStatus) values: [Get Server, OK]
    Possible solutions: setPropertyValue(java.lang.String, java.lang.String), getPropertyValue(java.lang.String)
    groovy.lang.MissingMethodException: No signature of method: com.eviware.soapui.impl.wsdl.WsdlTestCasePro.setPropertyValue() is applicable for argument types: (java.lang.String, com.eviware.soapui.model.testsuite.TestStepResult$TestStepStatus) values: [Get Server, OK]
    Possible solutions: setPropertyValue(java.lang.String, java.lang.String), getPropertyValue(java.lang.String)
    at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:55)
    at org.codehaus.groovy.runtime.callsite.PojoMetaClassSite.call(PojoMetaClassSite.java:46)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:120)
    at Script58.run(Script58.groovy:3)
    at com.eviware.soapui.support.scripting.groovy.SoapUIGroovyScriptEngine.run(SoapUIGroovyScriptEngine.java:96)
    at com.eviware.soapui.support.scripting.groovy.SoapUIProGroovyScriptEngineFactory$SoapUIProGroovyScriptEngine.run(SourceFile:89)
    at com.eviware.soapui.impl.wsdl.testcase.WsdlTestCase.runTearDownScript(WsdlTestCase.java:951)
    at com.eviware.soapui.impl.wsdl.support.AbstractTestCaseRunner.runTearDownScripts(AbstractTestCaseRunner.java:202)
    at com.eviware.soapui.impl.wsdl.support.AbstractTestCaseRunner.internalFinally(AbstractTestCaseRunner.java:183)
    at com.eviware.soapui.impl.wsdl.support.AbstractTestCaseRunner.internalFinally(AbstractTestCaseRunner.java:42)
    at com.eviware.soapui.impl.wsdl.support.AbstractTestRunner.run(AbstractTestRunner.java:163)
    at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
    at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
  • NLange's avatar
    NLange
    Occasional Contributor
    We found the solution for this problem. This issue can be closed/resolved.

    for( r in testRunner.results )
    {
    testRunner.testCase.setPropertyValue(r.testStep.name, r.status.asType(String));
    log.info "TestStep [" + r.testStep.name + "] " + r.status.asType(String);
    }