Forum Discussion

alvinkhow's avatar
alvinkhow
Occasional Contributor
5 years ago
Solved

Generate test step status to DataSink

I have create one test case with more than 100 test data for different condition/scenario in DataSource. 

At test step 3, i have add an assertion "Json_status" and "Json_statusMsg" to validate the test result in rest response..

So, how to add the test result (passed/failed) for each row test data based on status of assertion in test step 3 to property "finalTestResults"  in DataSink.

 

  • Do it in simple way and finally managed to get expected result

     

    ${=testRunner.results[testRunner.results.size()-1].status}

9 Replies

  • richie's avatar
    richie
    Community Hero

    Hi,

     

    I'm struggling to understand your description. You state you have one test case and 100 testdata files covering the different tests you want to exercise - so this is a looping test case - right?

     

    you state "at test step 3 you have add an assertion "json_status" and "json_statusMsg" to validate the response - but we don't know the significance of test step 3 - nor what "json_status" or "json_statusMsg" actually means.

    Q1.  What is test step 3? 

    Q2.  is this a REST/SOAP request? 

    Q3.  are json_status and json_statusMsg 2 attributes in the requests response?

     

    next you state "how to add the test result(passed/failed) for each for testdata based on status of assertion in step 3 to property "finalTestResults" in DataSink

     

    Q4. Is DataSink test step, step4 in your test?

    Q5.  Are you saying you have you want to write out the results of each of the test case loop's results (either pass or fail) to the property setup via the DataSink?

     

    Cheers,

     

    rich

     

     

    • sonya_m's avatar
      sonya_m
      SmartBear Alumni (Retired)

      Hi alvinkhow , please provide more details about your case as richie suggests so that the Community could help you more efficiently! 

       

      Thank you. 

  • alvinkhow's avatar
    alvinkhow
    Occasional Contributor

    Hi Rich,

    Basically my idea as below, i try to automate it to avoid manual work but I was new to soapUI and 0 knowledge in writing the script.  Sorry if i asking a silly question.

     

    My test step as below:
    1. DataSource

    testCase   Ccy             Tenor     Expected_Status   Expected_statusMsg
    TC_01      GBPUSD    SPOT    OK
    TC_02      EURUSD    SPOT    ERROR                  No rate available
    TC_03      AUDUSD    SPOT    OK
    TC_04      USDCAD    TODAY  ERROR                 Currency holidays

     

    2. DataGen
    3. Rest Request 1
    This step will send the request to get market rate.
    I have add and group this 2 assertion ("Json_status" and "Json_statusMsg") to validate the response with the expected result in step 1. If both match, then return PASSED to "finalTestResults" in DataSink else FAILED.

     

    4. Data Sink
    In this step i want to write out results for each test case loops to excel.
    testCase Ccy            Tenor     finalTestResults
    TC_01    GBPUSD   SPOT     PASSED
    TC_02    EURUSD   SPOT     FAILED
    TC_03    AUDUSD   SPOT     PASSED
    TC_04   USDCAD    TODAY   PASSED

     

    5. DataSource Loop

     

    Thank for you help.

      • sonya_m's avatar
        sonya_m
        SmartBear Alumni (Retired)

        Thank you a lot nmrao! 

         

        Hi alvinkhow , did you have a chance to take a look at the video nmrao provided? Was it helpful? 

    • alvinkhow's avatar
      alvinkhow
      Occasional Contributor

      Do it in simple way and finally managed to get expected result

       

      ${=testRunner.results[testRunner.results.size()-1].status}

      • richie's avatar
        richie
        Community Hero
        Hey alvinkhow,

        Great you found a solution and i need to apologise for not getting back to you. I don't know why but your post kept appearing on the second page when i view the forum on my laptop, so i just forgot about your query.

        Ta

        Rich