cancel
Showing results for 
Search instead for 
Did you mean: 

fill properties step from file

Contributor

fill properties step from file

I have 1 question.
When i fill the properties step from a groovy scrip.
(Just as your example in the help).

Do i have to see some changes in the properties step,
or do i load the Item in memory??

Regards,

Raymond
3 REPLIES 3
Super Contributor

Re: fill properties step from file

Hi Raymond,

how do you mean? You should see the assigned property values in the PropertiesStep editor.. you need to be sure that the properties exist or you will need to add them first (before assigning them a value) with

def propertiesStep = testRunner.testCase.getTestStepByName( "..." )
propertiesStep.addProperty( "myProperty" )
propertiesStep.setPropertyValue( "myProperty", ... )

Hope this helps!

regards,

/Ole
eviware.com
Contributor

Re: fill properties step from file

I ask this, because when i use the script below, the properties where not added.

// read the file
def properties = new java.util.Properties();
properties.load( new java.io.FileInputStream( "testprops.txt" ));

def targetStep = testRunner.testCase.getTestStepByName( "Properties" );

// assign single property
targetStep.setPropertyValue( "myproperty", properties.getProperty( "myproperty" ));

// assign all properties
def names = properties.propertyNames();
while( names.hasMoreElements() )
{
  def name = names.nextElement();
  targetStep.setPropertyValue( name, properties.getProperty( name ));
}


This is a script from the manual.
http://www.soapui.org/userguide/functio ... t_Examples
Super Contributor

Re: fill properties step from file

Hi!

Yes, this script requires that the properties in the file have already been defined in the properties step (which could be clarified in the docs..)

You can modify the script as follows to ensure creation of missing properties:

...
while( names.hasMoreElements() )
{
  def name = names.nextElement();
  if( targetStep.getProperty( name ) == null )
      targetStep.addProperty( name )

  targetStep.setPropertyValue( name, properties.getProperty( name ));
}
...

Hope this helps!

regards,

/Ole
eviware.com
New Here?
Join us and watch the welcome video:
API Testing Mistake #2
APITestingMistake#2
Top Kudoed Authors