cancel
Showing results for 
Search instead for 
Did you mean: 

Setting soapUI testCaseproperties from a groovy script running in another soapui project

SOLVED
Highlighted
Occasional Contributor

Setting soapUI testCaseproperties from a groovy script running in another soapui project

Hi to all,

I have this scenario, in which TEST_PROJECT1 and TEST_PROJECT2 are similar test project but must remain two separate projects. What I am trying to implement is a unique external script (in ENV_PROJECT) that is called from inside each test project, and it shoul be able to change testCase properties inside the test project itself.

For example:

- ENV_PROJECT

TestSuite

TestCase

groovySetPropStep

- TEST_PROJECT1

TestSuite1

TestCase1

groovyScript1

SoapRequestStep1A
SoapRequestSte1B

....

- TEST_PROJECT2

TestSuite2

TestCase2

groovyScript2

SoapRequestStep2A

SoapRequestStep2B

.....

Now when I execute dor example TestSuite1, groovyScript1 should be able to run groovySetPropStep (passing the TestSuite1 context) so that groovySetPropStep can set testCase properties of TestSuite1.

Is it possible?  Or is there an alternative way to reach my target?
Thanks in advance.

Ugo  

2 ACCEPTED SOLUTIONS

Accepted Solutions
Highlighted
Occasional Contributor

Re: Setting soapUI testCaseproperties from a groovy script running in another soapui project

I find it by myself, but put here the answer to help someone...

So groovyScript1 must have the following content

def project = testRunner.testCase.testSuite.project.workspace.getProjectByName("ENV_PROJECT")
project.testSuites['TestSuite'].testCases['TestCase'].testSteps['groovySetPropStep'].run(testRunner, context)

 

while the groovySetPropStep has for example the following content:

testRunner.testCase.setPropertyValue("propAOfTestCase1 ", "someValue");

.......

testRunner.testCase.setPropertyValue("propBOfTestCase1 ", "anotherValue")

 

I tried and it works... Good!

 

View solution in original post

Highlighted
Community Hero

Re: Setting soapUI testCaseproperties from a groovy script running in another soapui project

I don't think neither this is very common use case nor suggested to have dependency between projects.

By the way, the project won't run with testrunner which is way for the automation.


Regards,
Rao.

View solution in original post

3 REPLIES 3
Highlighted
Occasional Contributor

Re: Setting soapUI testCaseproperties from a groovy script running in another soapui project

I find it by myself, but put here the answer to help someone...

So groovyScript1 must have the following content

def project = testRunner.testCase.testSuite.project.workspace.getProjectByName("ENV_PROJECT")
project.testSuites['TestSuite'].testCases['TestCase'].testSteps['groovySetPropStep'].run(testRunner, context)

 

while the groovySetPropStep has for example the following content:

testRunner.testCase.setPropertyValue("propAOfTestCase1 ", "someValue");

.......

testRunner.testCase.setPropertyValue("propBOfTestCase1 ", "anotherValue")

 

I tried and it works... Good!

 

View solution in original post

Highlighted
Community Hero

Re: Setting soapUI testCaseproperties from a groovy script running in another soapui project

I don't think neither this is very common use case nor suggested to have dependency between projects.

By the way, the project won't run with testrunner which is way for the automation.


Regards,
Rao.

View solution in original post

Highlighted
Occasional Contributor

Re: Setting soapUI testCaseproperties from a groovy script running in another soapui project

Hi nmrao, I understand your point of view, but my need was to manage light soapui projects (in other words, not a huge size), to easily and quickly export and share them with other colleagues (If I group all testsuites in a single project i get it with 150 MB size and over).

That's why I had the requirement to set custom properties in an external project.

In this way, I can load only the small project and its own testsuites I need to run along with the very small project containing all custom properties needed. 

I can figure that this is not a "standard" scenario, but I can assure it works. I'm using it right now.  

New Here?
Join us and watch the welcome video:
Top Kudoed Authors