Forum Discussion

rohitvarsha12's avatar
rohitvarsha12
Contributor
8 years ago

Excel and HTML Report with test summary

Hello,

 

Is there any way After running Test suite I should Have Excel Report, which will list down Test case , test step and Its results(Pass/Fail) in Excel using SOAP UI PRO.

Also, Can I get count of Test cases executed, Passed, failed.

 

Itied to search on forum but at most of the places they have mentioned about using evenets.

 

I will really appreciate if you can share code for it.

 

2 Replies

  • I was able to create this with below code. Use excel or HTML whatever format you like. 

     

    Test Step Results along with Failed Assertion list:

    import com.eviware.soapui.model.testsuite.Assertable.AssertionStatus

     

    def file1

    def tcFailedStep

    def failedrequest

    def request

    def tcCreateApplication

    def rawResponse

     

    def assList

     

     

     if(new File('C:\\APIFramework\\groovy1.txt').exists())

     {

                log.info("----------------------File Exist----------------------")

                file1 = new File('C:\\APIFramework\\groovy1.txt')

               

     }else

     {

                log.info("File Does Not Exist")

                file1 = new File('C:\\APIFramework\\groovy1.txt')

     }

     

    def TestCase = testRunner.getTestCase()

    def StepList = TestCase.getTestStepList()

     

    StepList.each{

      

        if(it.metaClass.hasProperty(it,'assertionStatus')){

            if(it.assertionStatus == AssertionStatus.FAILED)

            {

                tcFailedStep="${it.name}"

                //file1.append "\n Failed Test Case Name = " + tcFailedStep

              file1.append "\n ${it.name} FAIL"

                            tcCreateApplication = TestCase.testSteps["${it.name}"]

                            //log.info context.testCase.getTestStepByName(“CreateApplication”).getProperty(“Request”).getValue()

                            request = tcCreateApplication.testRequest.response.getRequestContent().toString()

                            rawResponse = new String(testRunner.testCase.testSteps["${it.name}"].testRequest.response.rawResponseData)

     

                           

                            file1.append "Request for Failed Test Step" + request

     

                           

               

                tcCreateApplication.getAssertionList().each{

                            if("$it.status" == "FAILED")

                            {

                                        assList =  assList + "$it.label - $it.status" + ","

                                        }

                            }

                           

                            file1.append "\n" + assList

                file1.append "\n" +rawResponse

                            //log.info (rawResponse)

              

            }else if(it.assertionStatus == AssertionStatus.VALID){

                file1.append "\n ${it.name} PASSED"

            }else if(it.assertionStatus == AssertionStatus.UNKNOWN){

                file1.append "\n ${it.name} Not Executed (Disabled)"

            }

        }

    }

     

     

    1. Executing Test Case Based on Flag

    def groovyUtils = new com.eviware.soapui.support.GroovyUtils(context)

     

    //"TestData" is my datasource name

    def ds = testRunner.testCase.testSteps["TestData_CreateApplication"]

     

    def rr = ds.getPropertyValue('RunRow')

     

    log.info(rr)

    if ( rr == 'Y' ) {

                testRunner.gotoStepByName("GetCountyDetails_SubjectProperty")

    } else {

                testRunner.gotoStepByName("DataSource Loop")

    }