Ask a Question

Setting Custom Properties on project level through JUnit

EmilDK
Occasional Contributor

Setting Custom Properties on project level through JUnit

Hello!

 

I'm running automated SOAPUI tests through JUnit.

I've succeded transferred properties to the different Test Cases by sending a Map of different properties - but now I need to do the same on project level("Custom Parameters).

 

I've tried this:

 

SoapUITestCaseRunner runner = new SoapUITestCaseRunner();
runner.setProjectFile(folder + "\\" + s);
runner.setIgnoreErrors(true);
runner.setProjectProperties({"DbUsername=testuser","DbPassword=testpw"});
runner.run();

 

Unfortunately it doesn't work - the properties(e.g: #Project#DbUsername) remain empty when running the code.

 

Any ideas how to fix this? 🙂

9 REPLIES 9
nmrao
Community Hero

@EmilDK,

You have use as ${#Project#DbUsername}

For more details, refer documentation here:
https://www.soapui.org/scripting---properties/property-expansion.html


Regards,
Rao.
EmilDK
Occasional Contributor

Sorry for being inaccurate - I am using "${#Project#DbPassword}".

It works when putting in the properties manually under "Custom Properties" - but I can't set it automatically through JUnit.

nmrao
Community Hero

@EmilDK,

Would you mind showing your code which you are talking about?


Regards,
Rao.
EmilDK
Occasional Contributor

Capture.PNG

This is the Custom (project) Properties I'm referring to in my SOAP UI tests which runs fine.

 

But I need to change these properties through my JUnit project so I can execute my tests automatically on different environments(that has different usernames/passwords). However, it seems like the TestRunner.setProjectProperties() has no effect.

 

nmrao
Community Hero

Requesting you again for the code used in junit which you are talking about.


Regards,
Rao.
EmilDK
Occasional Contributor

Not sure what code you want. The relevant Java code from my JUnit test is posted in my first post.

nmrao
Community Hero

@EmilDK, sorry about it. Did not realize that.

May be you want to try as below:

runner.setProjectProperties(new String[]{"DbUsername=testuser","DbPassword=testpw"});


Regards,
Rao.
EmilDK
Occasional Contributor

NP :). But same result unfortunately

PaulMS
Super Contributor

You could save the project after run

https://www.soapui.org/apidocs/com/eviware/soapui/tools/SoapUITestCaseRunner.html#setSaveAfterRun(bo...)

 

like the command-line argument

-S: Commands the runner to save the test project after the test run finishes. Use this command-line argument if you store data within the project during the test.

https://support.smartbear.com/readyapi/docs/soapui/running/automating/cli.html

cancel
Showing results for 
Search instead for 
Did you mean: