Forum Discussion

ravibabu_it's avatar
ravibabu_it
Occasional Contributor
7 years ago

Issue in invoking rest method from another test suite using groovy script

HI All,

 

I am facing issue where i am unable to invoke rest step that exists in another test suite. When I ran the script, i am always getting "End point url not found". But when I execute the same step directly by clicking Run button it is working fine.

 

Here is the code that i used to invoke rest method from another test suite in same project.

 

ServiceName=context.testCase.testSuite.getPropertyValue("Service")
methodname=context.testCase.testSuite.getPropertyValue("Method")
context.testCase.testSuite.project.testSuites["Services"].testCases[ServiceName].testSteps[methodname].run(null,context)

 

I double checked the values printed in the log and it looks good. Not sure what's wrong with the above step. 

 

 

Please find the attached screenshots which might help in understanding the issue. Any help  is greatly appreciated.

 

 

 

 

7 Replies

  • nmrao's avatar
    nmrao
    Champion Level 3
    Not sure why null is passed to run method.
    Can you please try :
    ..run(testRunner, context)
  • ravibabu_it's avatar
    ravibabu_it
    Occasional Contributor

    Thanks RAO for the response . I have tried this earlier and now also  and got the same result.Let me share more details that might help in providing suggestions to this issue.

     

    When I invoke the rest method through groovy script, it looks like it is not passing parameter values.

     

     request: GET /DataVisionService/dh/login// HTTP/1.1

    DEBUG:Receiving response: HTTP/1.1 404 Not Found

     

    But when i execute the same request by clicking run button, it is successfully passing parameters and executing the request correctly.

    DEBUG:Sending request: GET /DataVisionService/dh/login/userid/password HTTP/1.1

    DEBUG:Receiving response: HTTP/1.1 200 OK

     

    Please find the attached screenshot of parameter substitution.

     

    Thanks,

    Ravindra

    • nmrao's avatar
      nmrao
      Champion Level 3
      Are those are properties set in that test case? or do you need to pass them from here?
      • ravibabu_it's avatar
        ravibabu_it
        Occasional Contributor

        I am creating and setting properties values  in the test case during run time..I checked and those properties are set correctly. Manually I have refereed those values in rest method as ${#TestCase#userid} .Please let me know if you need any more information. Thanks once again for looking into the issue.

         

         

        myTestCase.setPropertyValue(inputtagList,inputValueList)
        def x = myTestCase.getPropertyValue(inputtagList)
        log.info " x: $x"

         

        Thanks,

        Ravindra