Forum Discussion

mmethod's avatar
mmethod
New Contributor
10 years ago

An easy question related to the 'context' of my test step :)

Dear Experts,

 

I am new to this forum!  I had no other choice than registering as I am completely lost :)

 

I have been trying for days now to get test steps properly executed using a SoapUI Groovy script.

 

I have a test suite containing a single test case running one and only main script (Groovy) controling the entire flow of my test scenarios.

 

My requests are containing some property placeholders like ${#TestCase#PropertyX}.

 

Test cases are correctly executed and properties filled.

 

Instead of executing test cases I tried to execute each test step inside a specific test case one by one.

 

Steps are executed but property expansion doesn't work properly.  Requests are sent with some empty values.

 

According to me context isn't correctly set while executing steps.  It seems steps are executed but test runner is looking for properties somewhere else (in another test suite/case maybe?).  Reason why some of them can't be found resulting in empty values.  Probably test case execution works fine because properties are directly linked to it...

 

I tried so many things but nothing works.  Maybe it's due to ${#TestCase#PropertyX} referring to the wrong TestCase?  Maybe I have to clearly set the context of test runner before executing a specific test step in another test suite/case?

 

I think answer is quite obvious even if I didn't get it solved for now :(

 

Without going too much into details here are some lines of my code:

 

 

(...)

 

def reusableActionTestCaseSteps = reusableActionTestCase.getTestStepList()

 

(...)

 

reusableActionTestCaseSteps.each{
   tried this by doesn't work: myTestStepResult = it.run(testRunner, context)

   tried this by doesn't workmyTestStepResult = testRunner.runTestStep(it)
   tried this by doesn't work:

      def runner = it.run(null,true)

      runner.waitUntilFinished()

 

Steps are executed but placeholders aren't replaced by property values.

 

The following works fine:

 

reusableActionTestCase.run(properties, async)...

 

...but I don't want to execute a test case but steps inside of it!

 

Please help!

 

Thanks a lot in advance...

 

Best Regards,

 

Michael

  • kondasamy's avatar
    kondasamy
    10 years ago

    Michael,

     

    Not sure the below script helps your need; Please try and let us know,

     

    def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context );
    def testCase = testRunner.testCase;
    testRunner = new com.eviware.soapui.impl.wsdl.testcase.WsdlTestCaseRunner(testCase, null);
    def reusableActionTestCaseSteps = reusableActionTestCase.getTestStepList()
    reusableActionTestCaseSteps.each
    {
    	testStep->
    	testStepContext = new com.eviware.soapui.impl.wsdl.testcase.WsdlTestRunContext(testStep);
    	testStep.run(testRunner, testStepContext);
    }

    Thanks,

    Samy

  • mmethod's avatar
    mmethod
    10 years ago

    Hello,

     

    Thanks a lot for your reply!

     

    I'll directly give it a try...

     

    Hope it will work as I am working with WADL's and not WSDL's.

     

    Kind Regards,

     

    Michael

  • This would work irrespectiveof WADL/ WSDL. I guess you got confused on seeing the name - WsdlTestCaseRunner. Please share if this works or if you found any other work around.

     

    Thanks,

    Samy

  • testhrishi's avatar
    testhrishi
    Frequent Contributor

    May I know why do you want to run the steps using groovy scripts?

    • kondasamy's avatar
      kondasamy
      Regular Contributor

      Michael,

       

      Not sure the below script helps your need; Please try and let us know,

       

      def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context );
      def testCase = testRunner.testCase;
      testRunner = new com.eviware.soapui.impl.wsdl.testcase.WsdlTestCaseRunner(testCase, null);
      def reusableActionTestCaseSteps = reusableActionTestCase.getTestStepList()
      reusableActionTestCaseSteps.each
      {
      	testStep->
      	testStepContext = new com.eviware.soapui.impl.wsdl.testcase.WsdlTestRunContext(testStep);
      	testStep.run(testRunner, testStepContext);
      }

      Thanks,

      Samy

      • mmethod's avatar
        mmethod
        New Contributor

        Hello,

         

        Thanks a lot for your reply!

         

        I'll directly give it a try...

         

        Hope it will work as I am working with WADL's and not WSDL's.

         

        Kind Regards,

         

        Michael