Forum Discussion

RaghavanG's avatar
RaghavanG
Occasional Contributor
8 months ago

How to Generate Data correctly using datasource in readyAPI

I am getting the 2nd key value pair from map multiple times. Please help in it to find what I am doing wrong here.
  • TNeuschwanger's avatar
    8 months ago

    Hello @RaghavanG 

    maybe this code snippet can help (make sure to adjust line 1 to be whatever the name of your datasource is)...

    def row = testRunner.testCase.testSteps["Data Source 2xyz"].currentRow;
    
    def testDataMap = [TC01:'Pass', TC02:'Fail', TC03:'Fail', TCNN:'Pass'];
    
    if ( (row + 1) <= testDataMap.size() ) {
       result["TestCaseName"] = testDataMap.entrySet()[row].getKey();
       result["TestStatus"] = testDataMap.entrySet()[row].getValue();
    };

    Regards,

    Todd