Tutorial – External Data Sources in SOAPSonar

Entering input values for messages can be a manual task. However, when a large number of input values are involved this process can be automated by using external data sources such as RDBMS, Microsoft Excel Spreadsheets or flat files that contain input values.  In this tutorial, we will develop a test suite that uses an external Excel Data Source.

 This tutorial is a continuation of SOAPSonar Introduction Tutorial 2 – Functional Testing and has prerequisites from that Tutorial

Before starting this Tutorial, the user should ensure they switch SOAPSonar to QA Mode and Project view

1. Create & Populate an Excel Spreadsheet TestData.xls with the first row labeled as State and Population.  Populate the values in this spread sheet.  As sample Excel file is shown below.

Testdata2. Under the Configuration Node in the Project Tree, select Data Sources as shown in the Figure below.  Select Add Automation Data Source > Excel Data Source. Browse to the TestData.xls and COMMIT

AutoData 1

3. Verify that the Excel spreadsheet has been properly loaded, click on the spreadsheet name in t he list of data sources and then click on the REFRESH followed VIEW DATA buttons.  The Data contents of the spreadsheet will be displayed in the pop-up window.

Autodata 2

  4. For testing a Web Services API that returns state population we need to provide State as an input parameter. This value will populate directly from the above created Automation Data Source (ADS). Lets clone a new test first to work with and rename it Autostate in the same way we clones Maryland in Tutorial 2

Autodata 35. Go to your request and Put your cursor after “for=state:”. Right click to open submenu. Go to [ADS] Automation Data Source -> Quick Select->TestData.xlsx->State.  Notice as SOAPSonar automatically recognizes that the data source was added to the project and allows you to automate test input parameters.

 6. Once you select the Automatic Data Source (ADS) State as inputs for the request, unique reference IDs for the data sources starting with $ads: will appear.  COMMIT

 7. Go to Success Criteria tab delete anything entered here. We will create a new success criteria later in this tutorial. SAVE

 8. Go to the Run View clear out any other tests and Drag-and-Drop the Autostate  to Test Suite under the Default Group as shown in the Figure below.  COMMIT. The RUN. Once the test suite is executed, click on Analyze Results in Report View.  The test case iterates through all four State values and substitute values in the request as expected.

Autodata4

Testers can generate comprehensive test suite values by simply pointing to reusable data source such as an Excel spreadsheet or a RDBMS. Many of these are available free or commercially. Greatly reducing the time needed to run a test and increasing the number of possible inputs resulting in more testing and higher quality

So far we looked at Automating Requests using ADS. Now, let’s look at automating response validation from the service.

Autodata5 9) Go back to Project View and then Success Criteria Tab and add a new XPath Match criteria. SOAPSonar will automatically recognize that Web Service API response will be in JSON Format. Right-click on the JSON value 37253956 node and select Compare Element Value( to validate Population).

10. Go to Criteria Rules tab and delete hardcoded value 37253956.
Click on CHOOSE DYNAMIC CRITERIA. Select Current Variables-> $ads:Population:F09C24D4$. COMMIT the test. SAVE.

Auto 6

11. Go to Run View and RUN the test. Now SOAPSonar will not only look at the HTTP response code but also compare Value that was returned by the service with expected results stored in Excel file. Did all 4 pass?

12. Lets set one to fail. Go back and edit your Testdata.xls file with a line 6. Fill in say state 25 and put 25 under the population as well. Save your Excel file and rerun the test. Can you see 5 tests where now run and 1 failed?

Auto 7If you go to Analyze Results in Report View you can see Test 5 is red, selecting that you can see the response for state 25 is 6547629 and not 25 as we have in our data source.

By : Sergey Sadovnichiy /August 02, 2013 /All Posts, Technical Discussions /2 Comments

2 Comments

  1. Daniel August 8, 2013 11:27 pm Reply

    Nicely written tutorial Sergey! Reminds me of the old days what we first introduced SOAPSonar to RBC and I am happy to see how you turned it into a business – It is incredible how life takes us in different directions….

    BTW, you should also write a tutorial on how to simulate a more complex business flow (multi-step process), because I think you audience will find it helpful.

    Cheers my friend!

    • Sergey Sadovnichiy August 9, 2013 9:55 am Reply

      Hi Daniel,
      It is great to see that you still follow us and yes… you are right. Life is full of surprises.
      Thanks for your input on tutorials, we will publish one shortly.
      Cheers,
      Sergey

Post a Comment

Your email address will not be published.


Anti-Spam Quiz: