fill properties step from file
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-06-2007
07:56 AM
08-06-2007
07:56 AM
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
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
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-06-2007
08:40 AM
08-06-2007
08:40 AM
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
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
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-06-2007
09:54 AM
08-06-2007
09:54 AM
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
// 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
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-06-2007
10:15 AM
08-06-2007
10:15 AM
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
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
