Get/Set property Value of a Project from script
To be able to get a property value of a Project from the mock Service within the same project, you can use the below command under the Script of your mockService
def varProperty = mockResponse.mockOperation.mockService.project.getPropertyValue("someProjectProperty")And from a groovy script test step you can use
def testCaseProperty = testRunner.testCase.getPropertyValue( "MyProp" )To be able to set the same property with a different value using command you can use the below command
def testSuiteProperty = testRunner.testCase.testSuite.getPropertyValue( "MyProp" )
def projectProperty = testRunner.testCase.testSuite.project.getPropertyValue( "MyProp" )
def globalProperty = com.eviware.soapui.SoapUI.globalProperties.getPropertyValue( "MyProp" )
mockResponse.mockOperation.mockService.project.setPropertyValue("someProjectProperty", "NewValue")And from a groovy script test step you can use
testRunner.testCase.setPropertyValue("MyProp", "NewVal")To get/set values from the assertion script, you can use the below code in your assertion script. This kind of approach may help you with property transfer.
testRunner.testCase.testSuite.setPropertyValue("MyProp", "NewVal")
testRunner.testCase.testSuite.project.setPropertyValue("MyProp", "NewVal")
com.eviware.soapui.SoapUI.globalProperties.setPropertyValue( "MyProp", someValue )
messageExchange.modelItem.testStep.testCase.setPropertyValue("MyProp", "NewVal")You can repace the hard values with another variable to be able to optimize your code.
messageExchange.modelItem.testStep.testCase.testSuite.setPropertyValue("MyProp", "NewVal")
messageExchange.modelItem.testStep.testCase.testSuite.project.setPropertyValue("MyProp", "NewVal")
SoapUI : Fetching path of the project file
In order to fetch the current path of the project you can use the "projectPath" function of GroovyUtils. This example can be useful when you have to refer files which will be located within project however you do not want to perform modification every time you move them to another location on the same server or another server.
def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context )
def projectDir = groovyUtils.projectPath
def csvFilePath = projectDir + testRunner.testCase.testSuite.getPropertyValue( "externalFile" )
log.info "File : " + csvFilePath