Forum Discussion

678's avatar
678
Regular Contributor
7 years ago

How can I catch Testcase name from Datasource Row

I have a Datasource containing multiple rows with ex. Row1, Row2, etc., 

 

I wanted to report Row1 as a TestCase1 Name, and Row2 as a TestCase2 Name 

 

How can i explore this - i am using ReadyAPI Pro

  • avidCoder's avatar
    avidCoder
    Super Contributor

    Could you please explain or give some more insight for the same. What actually you want to report or validate?

    • 678's avatar
      678
      Regular Contributor

      I have Test cases on Excel for Every Row 1 = Testcase 1, Row 2 = Testcase 2, when i run a request i am getting report as Request Pass/Fail but not the Test case name from Excel 

      • New2API's avatar
        New2API
        Frequent Contributor

        Hi there, I am assuming that this is a data driven test and data is being used by a REST test step. you could add a groovy step to read Datasource data and dynamically update testcase name on the run.

         

        for Ex: your test case structure would be

         

        Datasource

        Groovy Script

        RestStep

        DataSource Loop

         

        Groovy script:

        //Variables to store datasource values
        def TestData = context.expand( '${DataSource#Row}' )
        
        
        //## get REST Step Name and dynamically change//
        def RestStep = testRunner.testCase.getTestStepAt(2)
            RestStep.setName("RestStep_$TestData")

         

         

         

         

  • Hi,

    I have implemented data-driven test through Excel except the below issue: 

     

    In My excel i have the first column as test case name. All I want is, running the test suite should get the test case name from the first column of the excel and run the test steps in subsequent columns.

     

    Let's assume if I have 3 test cases as below:

    1. Test Case - valid employee

    2. Test Case - valid address

    3. Test Case - valid car

     

    After running the test suite, I expect the below:

     

    Test Suite

        Test Case - valid employee

        Test Case - valid address

        Test Case - valid car

     

    I'm not sure where to have the DataSource, Groovy Script, Request and DataSourceLoop to accomplish the above.

    Attached file which i accomplished with the below issues:

    1. My Groovy script is updating the test step with the test case name instead of having a separate test case as mentioned above.