Forum Discussion

wdbian's avatar
Occasional Contributor
5 years ago

Run Test Case From Groovy Script


I have one question. On the right part of  below graph, two highlighted methods are used to call a test case of a different test suite from another test suite teardown script. The 1st one is creating a new testrunner which is not working; the other one is using the test case run() which works fine. What is the reason?


The SoapUI version is 5.5.0. 

5 Replies

  • shra1's avatar
    Senior Member


    Try the below code snippet:


    def targetTestCase= testRunner.testSuite.project.testSuites["TestSuite"].testCases["TestCase"]

    def targetContext= new WsdlTestRunContext(targetTestCase),targetContext)


    • wdbian's avatar
      Occasional Contributor

      Hi Shra1,

      I know in below way it is working. But my question is that with the last .run() clause it is the same as create a new test case runner. If my understanding is correct, I can use test case runner constructor to do that instead of run method. But in my case, constructor way is not working.


      def targetTestCase= testRunner.testSuite.project.testSuites["TestSuite"].testCases["TestCase"]

      def targetTestStep = testRunner.testSuite.project.testSuites["TestSuite"].testCases["TestCase"].testSteps["TestStep"]

      def targetContext= new WsdlTestRunContext(targetTestStep),targetContext)

  • nmrao's avatar
    Champion Level 3

    I understand that you are exploring the stuff.
    However, keep in mind that "no dependency between the test cases, each and every test case should be independent"

    Don't under stand by image what are you trying to achieve. Why script to generate report? Can't use standard Junit reports which are available?
    While there is runner variable, why creating another variable?

    There may be best solutions to suitable to the situations.
    Use case will help to understand the issue better.

    • nmrao's avatar
      Champion Level 3


      Marking this as solved. Please feel to reply if you have questions.