Forum Discussion

JParel's avatar
JParel
Occasional Contributor
8 years ago

Conditional GoTo Test Step on failed assertion

Hi,

 

I currently have a Datasource Loop which loops a few 100 calls using different endpoints. Within this loop, I want to write a Conditional GoTo step to write to a datasink when the previous service call step has a failed assertion. The Conditional Goto available will only go to the conditional step if the Condition matches an Xpath Expression however the service I am calling returns a JSON response and if I click on the 'ns:' icon in the Conditional Goto step, I get an error saying 'Missing response in previous request step [TestStepName]'. Is there a way to do what I want?

I forgot to mention that some of the assertion fails are due to 404 errors. Can I capture this as well in the Conditional GoTo step?

 

4 Replies

  • jays's avatar
    jays
    Occasional Contributor

    Instead of using 'Goto' test step, can you try using groovy script test step? This gives you more flexibility in catching 404 errors as well from other steps. 

    • JParel's avatar
      JParel
      Occasional Contributor

      @savithajay wrote:

      Instead of using 'Goto' test step, can you try using groovy script test step? This gives you more flexibility in catching 404 errors as well from other steps. 


      I would prefer not to write a groovy test script as I'm not that knowledgeable in writing code, but if I did what would the pseudo code look like?  

       

      also how would I structure the test case?

      This is what I envision

      step 1 run Datasource

      step 2 run JSON request with assertions 

      step 3 groovy test script to check for failed assertions in previous step

      step 4 only run Datasink to enter in failed request links

      step 5 run Datasource loop

       

  • nmrao's avatar
    nmrao
    Champion Level 3
    Add the assertion for response code in previous step itself to avoid.
    • JParel's avatar
      JParel
      Occasional Contributor

      nmrao wrote:
      Add the assertion for response code in previous step itself to avoid.

      Hi Rao,

       

      Sorry I didn't quite understand what you were trying to explain. You said put 'the assertion for response code in the previous step itself to avoid', what are you asking me to avoid? How would I get to input data into the DataSink with your method?