Forum Discussion

ashkht's avatar
ashkht
Contributor
8 years ago

How to catch current data row of datasource - TestSuite/TestCase Level using Groovy Script

Hello,

As per reporting part, I am trying to publish results on HTML Report. During this course of development, i am trying to show log for failed testcase with details like (TestStepStatus, TestStep Messages, Data Row # etc.) using testStepResult.messages by looping through testCaseResult.getResults(). But i am unable to show/log Data Row# from messages to HTML Report only for failed test case.

 

Can you please assist me with if condition, wherein i can capture Data Row# for failed test case based on testStep status or testCase status.

 

I tried to trouble shoot using below 2 ways but got stuck half the way. Please look into same:

#1. Adding a Groovy Step, trying to figure out if condition - based on testcase/teststep status so that i can get current data row from Data Source using below :

def row = testRunner.testCase.testSteps["DataSource"].currentRow

#2. Tried to figure out if condition - to be added in Tear down script at TestSuite Level, so that i can filter out and display only data row from messages for failed test case . (PFA attached groovy script added as Tear down script)

 

As per known fact, TestSuite doesn't have testRunner class hence i am seeking for assistance, so that i can achieve to publish results on HTML report.

 

Regards,

Ashish

  • Hi Ashish,

     

    Thank you for your post.

     


    ashkht wrote:

     

     

    As per known fact, TestSuite doesn't have testRunner class hence i am seeking for assistance, so that i can achieve to publish results on HTML report.

     


    If you want to use this script in the TestSuite Tear Down script, you can just use testSuite.getName() to get the Test Suite name.

     

    • ashkht's avatar
      ashkht
      Contributor

      Hello Anastasia,

      Thanks for your response!

      i am able to get testSuitename. My Question in this post is - how i can achieve to capture Data Row# for failed test case based on testStep status or testCase status at Teardown script at TestSuite level so that i can publish same to HTML report.

       

      Regards,
      Ashish