Ask a Question

How to write property value in setup script for test suiteS?

SOLVED
CXin
Frequent Contributor

How to write property value in setup script for test suiteS?

I need to set value to custom properties in setup scripts for all test suites.

Does any one know how to do that?

I tried all below scripts, neither of them work for me.


def testCaseProperty = testRunner.testCase.getPropertyValue( "MyProp" )

def testSuiteProperty = testRunner.testCase.testSuite.getPropertyValue( "MyProp" )

def projectProperty = testRunner.testCase.testSuite.project.getPropertyValue( "MyProp" )

def globalProperty = com.eviware.soapui.SoapUI.globalProperties.getPropertyValue( "MyProp" )


The error message always say couldn't find the property.

My understanding is the custom properties for all test suites are not project property or global project, it seems they are not testSuite property either...

Please kindly help
9 REPLIES 9
SmartBear_Suppo
SmartBear Alumni (Retired)

Hi,

How are you setting the property? The code you posted is getting the properties that should have already been set. If you would like to set the properties using groovy then the following methods will work.


testRunner.testCase.setPropertyValue( "MyProp", someValue )
testRunner.testCase.testSuite.setPropertyValue( "MyProp", someValue )
testRunner.testCase.testSuite.project.setPropertyValue( "MyProp", someValue )
com.eviware.soapui.SoapUI.globalProperties.setPropertyValue( "MyProp", someValue )


That comes from our Tips n' Tricks page here, http://www.soapui.org/Scripting-Propert ... properties.


Regards,
Marcus
SmartBear Support

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️

Hi,

 

I am trying to set property in project setup and tear down . But it is giving error as "groovy.lang.MIssingPropertyException: No such property: for testRunner class: Script 12"

 

I used: 

testRunner.testCase.testSuite.project.setPropertyValue( "Prop", Value) 

 

Please help on this how to resolve this issue or suggest me how t set project property under tear down step.

Hi,

 

I am trying to set property in project setup and tear down . But it is giving error as "groovy.lang.MIssingPropertyException: No such property: for testRunner class: Script 12"

 

I used: 

testRunner.testCase.testSuite.project.setPropertyValue( "Prop", Value) 

 

Please help on this how to resolve this issue or suggest me how t set project property under tear down step.

It suggests "Prop" does not exist at the project level. Can you try writing out the existing properties using getPropertyNames() in some sort of loop? And in the loop use log.info to write out the names?

CharlesHarold
Occasional Contributor

I found this thread when I was trying to accomplish the same thing.

 

In a project's Setup Script and TearDown Script, we have direct access to the 'project' object.

 

So, setting a custom project property is simply: 

project.setPropertyValue( "PropName", Value )

Getting all project custom properties:

def allProps = project.getProperties()

And removing a specific project custom property:

project.removeProperty( "PropName" )

I tried to set property at test suite level from Test Suite's SetUp script using the code you shared above. But that doesn't work.

It throws the following error

ERROR: com.eviware.soapui.support.scripting.ScriptException: Error in Setup Script of TestSuite

I tried to set property at test suite level from Test Suite's SetUp script using the code you shared above. But that doesn't work.

It throws the following error

ERROR: com.eviware.soapui.support.scripting.ScriptException: Error in Setup Script of TestSuite

CharlesHarold
Occasional Contributor

Since you are in the Test Suite Setup Script, the "project" object is not available (and you need to define the 'Value' property, if you haven't). Try:

String Value = "Some Value"
testSuite.setPropertyValue( "PropName", Value )

Thank You ! 

That works 🙂

cancel
Showing results for 
Search instead for 
Did you mean: