Forum Discussion

Tek_Travels_Pvt's avatar
Tek_Travels_Pvt
Occasional Contributor
10 years ago

How to get the Status of Each teststep without using Test testRunner.runTestStepByName

Hi Team

 

I am using ReadyApi version 7.1. I am facing a problem while using the below script GetDataSearch step is running thrice.

 

 

myTestStepResult = testRunner.runTestStepByName("GetDataSearch")

myStatus = myTestStepResult.getStatus()

 

Please find the attached logs and screenshots.

What I want to achieve is: 

To save the status of all TestStep results in SQL table.For that I am using Datagen and have written this code to return the status of the teststep.

 

Secondly is there any other method to get the status of teststep easily so that I can save it in db not in file because "testRunner.runTestStepByName" is creating a problem ,whenever I use this it skip all the other teststeps and start from the Datagen where the testRunnercode is written.

It always skips all the teststep like you can see in the screenshot and Transaction logs,its starting from Getdatasearch and skipping Credential Path step and Databag..

 

Thanks 

 

3 Replies

  • mishka's avatar
    mishka
    New Contributor

    hi ,

     

    Adding some scripts to get the test status results in the log ,

    hope it help.

     

    // get the testStep
    /*def testStep = testRunner.testCase.getTestStepByName('householdGet')
    // print assertion names an its status
    testStep.getAssertionList().each
    {
    log.info "$it.label - $it.status"
    }*/

     


    //---------------------------------------

    def soapStep = testRunner.testCase.testSteps["householdGet"]
    for( assertion in soapStep.assertionList )
    {
    log.info "Assertion [" + assertion.label + "] has status [" + assertion.status + "]"
    for( e in assertion.errors )
    log.info "-> Error [" + e.message + "]"
    }


    //---------------------------


    def responseStatus

    def listOfAssertions = testRunner.getTestCase().getTestStepByName("householdGet").getAssertionList()

    for (assertion in listOfAssertions)

    {

    // You can get the status of any assertions and here I am getting the value for NotSoapFaultAssertion

    if (assertion instanceof com.eviware.soapui.impl.wsdl.teststeps.assertions.soap.NotSoapFaultAssertion)

    responseStatus= assertion.getStatus()

    responseStatus = responseStatus.toString()

    }

     

    log.info "responseStatus is : $responseStatus"

     

    if (responseStatus == "VALID")
    {

    log.info "Proceed To Validation"

    }

    else {

    log.info "Skip Validation"

    }

     

    • Tek_Travels_Pvt's avatar
      Tek_Travels_Pvt
      Occasional Contributor

      Hi 

      Thanks for the solution but I want to save the status of each step in db.How this can be done.Please help

      • mishka's avatar
        mishka
        New Contributor

        hi ,

         

         I dont know how to save it in DB never tried it , but you can save it in TXT files ,

         

        If you will do simple looping on the response and refer it to the TXT file ,

         


        import java.io.BufferedWriter;
        import java.io.File;
        import java.io.FileWriter;
        import java.io.IOException;

         

        File file = new File("C:/Users/Desktop/[folder name]/file name --> it can be varible.txt"); //it will create the file

         


        FileWriter fw = new FileWriter(file.getAbsoluteFile());
        BufferedWriter bw = new BufferedWriter(fw);

         

        bw.write([your value] + System.lineSeparator());//new line

         

        bw.close();//close the write to the file

         

        hope it helped.:)