John Saunders
John Saunders

Reputation: 161821

Pattern for Credentials in soapUI Test Suites

I'm new to using soapUI for automated testing, so this is probably a dumb question.

I would like all of the test cases in my test suite to use the same username and password. Of course, I do not want the username and password stored in the soapUI project, nor in fact do I want them to be checked into source control.

I see that there's an ability to use custom properties at several levels of the hierarchy (Project, Test Suite, Test Case, Test Step, maybe more). I see that it's possible to load those properties from a file. I have successfully created "Username" and "Password" properties at the project level, and loaded them from a file (one which is not saved into source control).

I see that one kind of test step you can add is a property transfer step, and I have successfully used one to transfer the project-level properties to a test case request step.

What I want to know is some good patterns for getting such "global" properties into all test cases. Do I need to put a property transfer step into every test case? Is there an easy way to ensure that these property values do not get saved into the project file? Is there anything special that needs to be done for load testing to work?

Upvotes: 0

Views: 697

Answers (1)

Abhishek Asthana
Abhishek Asthana

Reputation: 1855

The project level properties can be accessed directly in all test suite/test cases/test steps within the scope of the project.

This can be done using the below format. In this format PropName is the name of my project level property. Just replace PropName with the name of you property and you are good to go.

${#Project#PropName}

If you need to access this property in a groovy step then you should use context.expand to get the value. SOmetime on the line of...

context.expand("${#Project#PropName}")

To access test Suite level properties in all the test cases/test steps with the test suite use..

${#TestSuite#PropName}

In Groovy test step

context.expand("${#TestSuite#PropName}")

To access test case level property in all test steps within its scope use the following format

${#TestCase#PropName}

In a groovy test step

context.expand("${#TestCase#PropName}")

To access properties of a test step in its sister test steps use...

${Test Request#Response}

where Test Request is the name of the test step and Response is the property you want to access.

The thing to keep in mind is the scope meaning, a project level property will be accessible in all its children but the properties of a test suite will not be accessible in another test suite.

As for using a property transfer step, i wouldn't recommend using it in this case. It should be used when for example you want to extract a value from a service's response and use to somewhere else.

When you are setting these properties at the project/test suite/test case level you need to set it like below. enter image description here In this image PropName is the name of the property and Somevalue is the value of the property. This is how the properties will be set when you are reading the properties from a file.

Now if you want to access this property in say a JDBC step you can just mention ${#Project#PropName} and when the step is run soapUI will replace ${#Project#PropName} with the actual value of the propety.

You can also check out soapUI guide on working with properties.

Hope this helps.

Upvotes: 1

Related Questions