Forum Discussion

amarnath1234's avatar
amarnath1234
Contributor
6 years ago
Solved

html report format issue

hi,

I want to generate HTML report for my execution,so for that i designed Setup script and Teardown script which is working fine If my testcase have teststeps only (attached script and report(screen-1))-i.e 1 request or multiple requests but if my testcase have requests with datasource and Datasink or any of the testcase is disabled then i am unable to generated report-error message displayed(screen 2),not sure how to fix this issue.need help.

I have attached both the setup script in text file.

error detail

"com.eviware.soapui.support.scripting.ScriptException: Error in TearDown Script of I1_TS3_Recommendation Dedupe/Merge/Sort"

  • this is working fine,Thanks for your help.

     

    below is the script.

     

    def testStepName
    def method
    def statusCode
    def endpointURL
    def str
    testCase.testStepList.each{
    testStepName = it.name
    if(it in com.eviware.soapui.impl.support.http.HttpRequestTestStep){
    method = it.getHttpRequest().getResponse().getMethod()
    statusCode = it.testRequest.response.responseHeaders["#status#"][0]
    endpointURL = it.getHttpRequest().getResponse().getURL()
    str = "<tr><td>${testStepName}</td><td>${method}</td><td>${statusCode}</td><td>${endpointURL}</td></tr>"
    file.append(str)
    log.info method
    log.info statusCode
    log.info endpointURL

    }
    }
    file.append("</tbody></table></HTML>")
    file.close()

2 Replies

  • Radford's avatar
    Radford
    Super Contributor

    I think the issue is that you are assuming all test steps have the getHttpRequest() method which they don't. getHttpRequest() is specified in the interface HttpRequestTestStep, thus the test step you are checking must implement this interface.

     

    A simple solution would be to check to see if each step implements the interface (using the Membership operator 'in') before you check the status. something like:

     

    testCase.testStepList.each{
        testStepName = it.name
        
        if(it in com.eviware.soapui.impl.support.http.HttpRequestTestStep){
            method = it.getHttpRequest().getResponse().getMethod()
            statusCode = it.testRequest.response.responseHeaders["#status#"][0]
            endpointURL  = it.getHttpRequest().getResponse().getURL()
    
            str = "<tr><td>${testStepName}</td><td>${method}</td><td>${statusCode}</td><td>${endpointURL}</td></tr>"
            file.append(str)
        }
        
    }

     

    Obviously you might want to do something else if the step doesn't implement HttpRequestTestStep rather than just ignore it as my above example does.

     

    I haven't had time to verify my code this, but hopefully should get you going.

    • amarnath1234's avatar
      amarnath1234
      Contributor

      this is working fine,Thanks for your help.

       

      below is the script.

       

      def testStepName
      def method
      def statusCode
      def endpointURL
      def str
      testCase.testStepList.each{
      testStepName = it.name
      if(it in com.eviware.soapui.impl.support.http.HttpRequestTestStep){
      method = it.getHttpRequest().getResponse().getMethod()
      statusCode = it.testRequest.response.responseHeaders["#status#"][0]
      endpointURL = it.getHttpRequest().getResponse().getURL()
      str = "<tr><td>${testStepName}</td><td>${method}</td><td>${statusCode}</td><td>${endpointURL}</td></tr>"
      file.append(str)
      log.info method
      log.info statusCode
      log.info endpointURL

      }
      }
      file.append("</tbody></table></HTML>")
      file.close()