cancel
Showing results for 
Search instead for 
Did you mean: 

fill properties step from file

Highlighted
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
Highlighted
Super Contributor

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

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
Highlighted
Super Contributor

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:
Announcements
TechCorner Leaderboard
Want a fun and easy way to learn ReadyAPI and show off your skills? Try solving weekly TechCorner challenges and get into the Leaderboard!


Challenge Status

Get a full Raw JMS request

Participate!

Compare an expected JSON value and actual response in Events

Participate!

Fetch value/data from JSON response using Groovy Script

See replies!

Get data from Petstore and add it to Excel sheets

Participate!
Top Kudoed Authors