0

I have two separate projects in SoapUI. I need to transfer a property from Project 1 to Project 2.

Also every time Project 2 is executed I need it to run a test case within Project 1 to get an updated property value.

Project 1

  • Request-Add A Person (returns with id)

Project 2

  • Request-Post a Photo(needs updated id from project 1)

I found a Groovy script that will take a property from another project.

testRunner.getTestCase().getTestSuite().getProject.getWorkspace().getProjectByName(project name)
testSuite = project.getTestSuiteByName(suite_name);
testCase = testSuite.getTestCaseByName(testcase_name);

However I am stuck on how to run a test case in a different project with a Groovy script

Rao
  • 20,781
  • 11
  • 57
  • 77
  • It is good practice that each and every test case is independent. However, you are bringing in dependency between two project which is not suggested. Probably you should change your test case design. – Rao Aug 02 '17 at 13:28
  • Hello Rao, Yes I completely understand. I have brought this up many times with my team and it does not appear I can do this any other way. These projects both represent two seperate services. Project 2 is dependent on Project 1. – Humanid 1652487954543 Aug 02 '17 at 13:39
  • With this approach, even if you achieve what you want, it will not scale / sustain for long to achieve end to end automation, I guess. – Rao Aug 02 '17 at 13:47
  • You still be able to add the service / wsdl in project2, right? – Rao Aug 02 '17 at 13:47

1 Answers1

6

You need to call run() on the testCase you wish to run :

testCaseToRun = testRunner.testCase.testSuite.project.workspace.getProjectByName('Request-Add A Person').testSuites['TestSuiteContainingTestCaseToRun name'].testCases['TestCaseToRun name']
testCaseToRun.run(null,false)
idToTransfer = testCaseToRun.getPropertyValue('idFieldName')
Tom
  • 106
  • 4
  • please dont post code-only answers, explain what your code is doing and how it should help OP – Luca Aug 08 '17 at 14:24
  • Thank you Tom. I have been struggling with this problem for awhile and could not find any good resource online. Could you share with me how you learned to use Groovy Script with SoapUI? Was there a resource that helped you the most? I'm just at a roadblock with finding any material that teaches me how to use Groovy Scripts WITHIN SoapUI. Thanks again – Humanid 1652487954543 Aug 08 '17 at 18:09
  • @StewartMoon thank you. Could you please explain briefly about run() parameters? why do you send first null and second as false, any reason? – Optimworks Aug 09 '17 at 06:57
  • You can find apidoc on run function here : http://www.soapui.org/apidocs/com/eviware/soapui/model/testsuite/TestRunnable.html#run-com.eviware.soapui.support.types.StringToObjectMap-boolean- As for ressources, I would recomand : - https://learnsoapui.wordpress.com/ - Groovy Goodness Notebook Cheers – Tom Aug 09 '17 at 19:55