Forum Discussion

scr's avatar
scr
Occasional Contributor
15 years ago

reset request to 'default' after property transfer

Hi there...

Is there a way to reset a request to a default or blank state during a test case run (something in groovy script maybe?).

I've been sifting through API but can't get a handle on it.

Manually, you can click the "Recreates a default request from the schema" button... can this be automated?

Kind regards,

S

4 Replies

  • sinnes_1's avatar
    sinnes_1
    Occasional Contributor
    In my soap requests, I refer to a Properties step rather that using a property transfer (still not 100% what they do ). Then I use groovy scripts to change these properties when I need. If I had a Properties step call "Properties" with the property "ID" inside it, I'd refer to it in a test request like so:

    <someelement>${Propreties#ID}</someelement>


    Then you can have a groovy script on either side of the request that manipulates the value of "ID" whenever you like.

    def properties = testRunner.testCase.getTestStepByName("Properties");
    properties.setPropertyValue("ID", "7");


    So you could have a groovy script underneath your test request that sets the properties back to whatever your defaults are.


    Hope that helps!
  • scr's avatar
    scr
    Occasional Contributor
    Hmm thanks, I was hoping there would be an easier way to do it than manually clearing all the properties, as my code doesn't necessarily carry the state of the XML with it (as in doesn't need to know which properties have been updated - nor does it need to know what properties actually exist in the request) as part of my keyword approach.

    maybe a better way wuold be to have a 'template' and automate the overwrite copy in before starting the next requests updates?

    kind regards,

    S
  • scr's avatar
    scr
    Occasional Contributor
    F/U:
    I have indeed cloned a 'template' request over the original that had garbage in it, using groovy.

    A colleague suggested using mockrequests for this same feature but I haven't learnt that yet.
  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    Hi!

    you can do this with a groovy script rather easily.. perhaps in the tearDown script of your testcase you would localize all teststeps that need to be reset and then..


    testStep.testRequest.requestContent = testStep.operation.createRequest( createOptional )


    Does that suffice?

    regards!

    /Ole
    eviware.com