jehon
jehon

Reputation: 1668

In SoapUI, in command-line, how to export some properties to another project?

In SoapUI, I have a lot of projects (separate xml files):

In the GUI, I simply use the transfert step to pass the value to a global property, and it works great.

In the command line testrunner.bat, I first run the "init.xml" project, then the other one (other.xml). But in the other.xml, the sessionId is not set. How could I export the sessionID from the init.xml run to the "other.xml" run?

Here is what i did test:

I would like to avoid merging all my project into one project.

Thanks

Upvotes: 0

Views: 845

Answers (2)

Rao
Rao

Reputation: 21379

The initializations required for a project have to be done in the same project which is good practice.

But you are doing different, not sure why it is being like that. If possible, make each project independent.

If you still want to achieve in the same way that you are doing currently, then use below:

What happens when the project(init.xml) is run from command line?

The changes that you expect are done in the memory and those data is available in other projects when you from within SoapUI since that data is available in memory. However not persisted to project (init.xml) once testrunner is finished with execution.

What should be done in order to persist data?
You need to add an additional command-line option, -S, in order to persist the data to the project.

For example, let us assume below command is used to run init.xml.

testrunner.bat [some options] init.xml

Change the above to below:

testrunner.bat [some options] -S init.xml

And when the second project is run, then it can pick the data from init.xml since those changes happened earlier are persisted.

Hope this is helpful.

Upvotes: 0

Torsten Küpper
Torsten Küpper

Reputation: 196

To use the common initialization of properties from init.xml, you could import the init.xml from within the load script of other project other.xml as follows:

def initProject = null
if (project.workspace == null) {
    // Case running from command line - loading the init.xml
    initProject = new com.eviware.soapui.impl.wsdl.WsdlProject("init.xml")
} else {
    // Case in GUI having a workspace - put in correct project name
    initProject = project.workspace.getProjectByName("Init")
}
// Invoke test case which sets up global properties
def initCase = initProject.testSuites["foo"].testCases["bar"]
testCase.run(new com.eviware.soapui.support.types.StringToObjectMap(), false)

Upvotes: 0

Related Questions