Forum Discussion

davecoleman's avatar
davecoleman
Contributor
3 years ago

One Excel Datasource and Multiple Test cases using Specific Test Case ID within source

Hi, I have the following excel source file 

Test Case IDCustomerID
test001Cust 001
test002Cust 002
test003Cust 002

 

I want to setup Testcases for e.g. Test002 that is picks up the value of "Cust 002" (which changes from day to day) and check the response via assertion that its correct.

 

how do I parse the excel file and find "test002" and input that value to that testcase only?

 

I would envisage the layout to be:

- Datasource

- "test001"REST step

- "test002" REST step

- "test003" REST step

- datasource loop

 

Looks like Groovy script is needed but there could be 100 testcases and associated data in the source file.

Thanks Dave

other examples with no answers: https://community.smartbear.com/t5/ReadyAPI-Questions/How-to-use-DataSource-and-DataSource-Loop-in-multiple-test-cases/m-p/150457

https://community.smartbear.com/t5/ReadyAPI-Questions/One-datasource-Excel-and-Multiple-Test-Cases/m-p/146569?search-action-id=42105450853&search-result-uid=146569

8 Replies

  • Working through a Proof of concept i have come up with the below solution:

    - A groovy script goes to each testcase as per the testcase Identifier in the data source.

     

    Datasource excel

    Groovy to decide on which step to go to:

    import com.eviware.soapui.support.XmlHolder
    
    def testcaseNo = context.expand('${Data Source#TestcaseId}')
    
    log.info (testcaseNo)
    
    if (testcaseNo=="test001")
    {
    log.info ("go to test step: " + testcaseNo)
    testRunner.gotoStepByName (testcaseNo)
    }
    else if (testcaseNo=="test002")
    {
    log.info ("go to test step: " + testcaseNo)
    testRunner.gotoStepByName (testcaseNo)
    }
    else if (testcaseNo=="test003")
    {
    log.info ("go to test step: " + testcaseNo)
    testRunner.gotoStepByName (testcaseNo)
    }
    else if (testcaseNo=="test004")
    {
    log.info ("go to test step: " + testcaseNo)
    testRunner.gotoStepByName (testcaseNo)
    }
    else if (testcaseNo=="test005")
    {
    log.info ("go to test step: " + testcaseNo)
    testRunner.gotoStepByName (testcaseNo)
    }

     

    Groovy after each step to move to the loop and start again on next row:

    import com.eviware.soapui.support.XmlHolder
    
    testRunner.gotoStepByName ("Data Source Loop")
    log.info ("moved to the Data Source Loop")

    It will work for myself but there may be better solutions out there.

     

     

    • ChrisAdams's avatar
      ChrisAdams
      Champion Level 2

      Hi Dave,

       

      You have Datasource's which I guess means you have the licensed version of SoapUI.

       

      Datasources and datasource loops are for data driven (aka functional) tests whereby you exercise one or more service calls using the datasource values as parameters for the service call(s).

       

      The most simplest example might look like

       

      Assuming the data source content looks like this....

      Customer IDCustomer Name
      1John
      2Paul
      3George
      4Ringo

       

      The Datasource would look like this....

       

      The service call being exercised then needs to pick up the Customer Id to use in this iteration.  E.g.

       

      The $ syntax above reads the current customerId value from the datasource.

      You can type this directly, or use the nifty Get Data option.  Click in the Value cell and ensure the cursor is there.  Sometimes you have to double-click.  Then right-mouse click to open the context menu.  Select Get Data.

      The Get Data screen allows you to navigate around your Workspace to select the value you want to pull in.  E.g.

       

      If you've followed this far, you'll see that using the datasource and 'Get Data' you can exercise one service call with almost unlimited values.  You don't need separate service call test steps per row in the datasource.

       

      You could then extend the test to call additional services to form sort of use case.  E.g.  Get Customer, Amend Customer, Customer places order.  Each step would be called once per iteration...

       

       

      IMHO, the data-driven tests are the best feature of ReadyAPI and are definitely worth persevering with.

       

      Here is a link to SMartBears own guide... https://support.smartbear.com/readyapi/docs/testing/data-driven/index.html?sbsearch=Data%20Driven%20Tests

       

      • davecoleman's avatar
        davecoleman
        Contributor

        That makes sense (and I use each day) if you want to use data from "Row 1" in each "Test Step Request".

         

        but in my example, I will have different assertions for each "Test Step Request".

        e.g. Row 1 data for Customer ID1 will have credit limit of 1000 and current sale = 1200 so ASSERTION is FAILED CREDIT CHECK.

        Row 2 data for CUSTOMER ID 2 will have credit limit of 1000 and current sale = 900 so ASSERTION wil be to check that response is PASSED CREDIT Check. 

         

        Each test step will have a different test result. I could create multiple Test cases in ReadyAPI but that would mean having multiple datasources to manage with 1 test entry in each excel. messy.