cancel
Showing results for 
Search instead for 
Did you mean: 

Run Test Case From Groovy Script

SOLVED
Highlighted
Occasional Contributor

Run Test Case From Groovy Script

Hi, 

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. 

snapshot.jpg

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Hero

Re: Run Test Case From Groovy Script

@wdbian,

Not sure what's wrong that you were doing. May be trivial.

Tried doing based on the image. Here is the sample project came up with to see that it is possible.

https://github.com/nmrao/sample-soapui-projects/blob/master/run-test-case/with-suite-setup/README.md


Regards,
Rao.

View solution in original post

5 REPLIES 5
Highlighted
Senior Member

Re: Run Test Case From Groovy Script

 

 

Try the below code snippet:

 

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

def targetContext= new WsdlTestRunContext(targetTestCase)

targetTestCase.run(testRunner,targetContext)

 

Highlighted
Occasional Contributor

Re: Run Test Case From Groovy Script

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)

targetTestCase.run(testRunner,targetContext)

Highlighted
Community Hero

Re: Run Test Case From Groovy Script

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.



Regards,
Rao.
Highlighted
Community Hero

Re: Run Test Case From Groovy Script

@wdbian,

Not sure what's wrong that you were doing. May be trivial.

Tried doing based on the image. Here is the sample project came up with to see that it is possible.

https://github.com/nmrao/sample-soapui-projects/blob/master/run-test-case/with-suite-setup/README.md


Regards,
Rao.

View solution in original post

Highlighted
Community Hero

Re: Run Test Case From Groovy Script

@wdbian 

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



Regards,
Rao.
New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors