Forum Discussion

AnandKiran's avatar
AnandKiran
Frequent Contributor
16 years ago

How to get the Status of the teststeps under a testcase

Hi,

I want  to get the no of teststep under and Testcase and also their respective names . Any idea how to do it using groovy????

Regards
Anand

4 Replies

  • AnandKiran's avatar
    AnandKiran
    Frequent Contributor
    I have retrieved the list of teststeps under a Testcase using the below code

    def testcase = testRunner.getTestCase();
    def steplist = testcase.getTestStepList() ;
    String[] list = steplist.name
    len = list.length;
    log.info len

    for(i=0;i{
    log.info list

    }

    Now I want to get the status of each step (whether the Status is OK/ Failed), can anyone suggest me an idea how to go about it.

    Regards
    Anand
  • AnandKiran's avatar
    AnandKiran
    Frequent Contributor
    I have used the below line to get the status of the Teststep,
    def result = testRunner.runTestStepByName( "Input" )

    But I dont want to do in this way. I have the follwing Test Steps in my testcase
    1. Input
    2. Request
    3. Status Check - Groovy script to get the status of the above two steps.

    If I use 'def result = testRunner.runTestStepByName( "Input" )' in the step 3 it will execute the step 1 again.

    Hope I am clear in exlpaining my issue. Please suggest me an idea to overcome this

    Note: I dont want to disable the teststeps.

    Regards
    Anand.
  • AnandKiran's avatar
    AnandKiran
    Frequent Contributor
    Hi,

    I found out the way to get the test step Status. hope it might be useful

    def list1 = new ArrayList()
    def count1 = 0
    for( r in testRunner.results )
    {

       count1++
       def item = "TestStep " + r.testStep.name + " finished with status " + r.status + "Time Taken ::" + r.timeTaken + "ms" 
       list1.add(item)



    }
    for (values in list1)
    log.info "Collected  Values are "+ list1