Forum Discussion

NadiaRanalli's avatar
NadiaRanalli
New Contributor
3 years ago

Check assertion for all test steps

Hi,

 

wondering if it is possible to run a test case to check assertions for all test steps performed before, instead of adding the same assertion to all test steps. See below, I would need to add the same assertion for all those test steps:

 

The assertion would be to check that each response contains the same data below in bold:

 

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<InterConnectResponse xmlns="http://xml.equifax.com/XMLSchema/InterConnect">
<SchemaVersion>2.0</SchemaVersion>
<InteractionControl>
<MessageId>5050</MessageId>
</InteractionControl>
<TransactionStatus>completed</TransactionStatus>
<WorkItem>N</WorkItem>
</InterConnectResponse>
</soapenv:Body>
</soapenv:Envelope>

 

 

Thanks a lot!

3 Replies

  • ChrisAdams's avatar
    ChrisAdams
    Champion Level 3

    Hi,

     

    In this case and based on the following assumptions from your question...

    • The assertion is the same for every step
    • Each step is within a single test case
    • I do not want to update each step to add the same assertion and that would be a pain.

    I would add a single groovy script as the last step in the test case.  The Groovy script would iterate over each test step and then check the values of interest.

     

    Luckily, some SmartBear people and contributors have been writing some guides.  https://community.smartbear.com/t5/Technical-Articles/tkb-p/readyapi-community-techarticles

    There is one you might find especially useful... https://community.smartbear.com/t5/Technical-Articles/How-to-capture-teststep-status-as-pass-fail-using-groovy-to/ta-p/223362.  This at least will guide in you in how to iterate over the test steps, but it mentions assertion status, which you won't have because you have not applied to the assertion to each.

     

    Another approach... It looks like you're calling the same service lots of times with different payloads.  You might want to look up data-driven tests whereby for each row in some datasource, you call the same service in a loop but the values change for each row.  If that's the case, then you only need one webservice call and therefore, only one assertion to apply.

    • NadiaRanalli's avatar
      NadiaRanalli
      New Contributor

      Hi Chris,

       

      Thanks a lot for your response but I would really appreciate if you could help me to write the actual script as I am not a dev and I wouldn't be able.

      Here the info:

      SOAPUI project: STS_CompanyRetrieval

      SOAPUI TestSuite: Request_ErrorManagement

       

      Thanks a lot!

      Nadia

      • ChrisAdams's avatar
        ChrisAdams
        Champion Level 3

        Hi,

         

        I'm happy to help, but not to build your solution from scratch.  Take a look at the guides and have a go then post what you've come up with and there are plenty of people who can help.

         

        What ever I/we provide is not likely to be perfect as we don't have access to the API you're calling, so even if I did provide something from scratch you would probably need to amend it.

         

        It's probably worth re-reading my earlier post to think about which approach you'd prefer.  For example, if you have the Pro licensed version, then I would definitely recommend the data-driven approach.  If you're using the free open-source version, then I'd suggest running the checks in the test tear-down (https://support.smartbear.com/readyapi/docs/functional/scripts.html)

         

        You don't have to be a dev to write some Groovy script and if you are moving into API development, then now is a great opportunity to learn some scripting and call on here for help.