Forum Discussion

Defender's avatar
Defender
Contributor
13 years ago

[Resolved]REST test request step from REST request in JS

Hi!
I have a request in a myRequest1 variable.
I have a test case in a myTestCase1 variable.

How can I add REST Request step to the myTestCase1 using the myRequest1 as request for this step in Javascript?

4 Replies

  • No answers... OK, I try to describe the problem more detailed:
    I have my test case in testCase1 variable.
    As I can see from Javadoc, the WsdlTestCase class contains
    addTestStep(java.lang.String type, java.lang.String name)
    method.
    I have no detailed description in this Javadoc, but I suppose this method uses for adding a new test step for the testCase1.
    The question on this stage is: what is the "type" parameter I need to pass into the method? I try to fill it with name of class which my step should correspond (it is the RestTestRequestStep) so my call looks like
    testCase1.addTestStep("RestTestRequestStep", testStepName);
    , but I receive null pointer exception here when I try to run my script. What am I doing wrong?
    Another way to add the test step is to use
    addTestStep(com.eviware.soapui.config.TestStepConfig stepConfig)
    , but com.eviware.soapui.config.TestStepConfig is not described in Javadoc. Could you please describe how to use it?

    The second thing is: when I use SoapUI to add the test step - I use the request as a source for it.
    Taking a look on the RestTestRequestStep class I cannot see the direct possibility to configure the source request for the test step. The only thing I see is
    setRestMethod(RestMethod method)
    , but this one configures the method instead of the request. The request may contain some setting differ from method settings & this confuses me. Could you please advice me in this?

    The answer in Javascript is preferred.
  • Guys, I need your answer ASAP. I cannot move forward without it.
  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    Hi,

    sorry for the delay here.. if myRequest1 is a REST request you should be able to use

    import com.eviware.soapui.impl.wsdl.teststeps.registry.RestRequestStepFactory

    myTestCase1.addTestStep( RestRequestStepFactory.createConfig( myRequest1, "TestStep name" ))


    Does that work better?

    regards!

    /Ole
    SmartBear Sweden