Forum Discussion

raj123456's avatar
raj123456
Occasional Contributor
9 years ago

HTML report without maven or ant in groovy

Hi All,

 

Have nearly 100 Methods and 250 operations in my project 

 

using one parameter file to pass the inputs to the methods

Below code which using in Groovy method and it is executing all the methods 

 

 

for(project in com.eviware.soapui.SoapUI.workspace.projectList){
if(project.open && project.name != testRunner.testCase.testSuite.project.name){
project.run(null,false)
} }

 

 

Now want to save and see the report how many methods are passed and how many Failed

is there any method to store the reports?

 

Thanks in advance

    • raj123456's avatar
      raj123456
      Occasional Contributor

      hi
      we are not using any maven or ant

      we will execute the scripts on request basis.

      • nmrao's avatar
        nmrao
        Champion Level 3

        Below script is taken from SoapUITestCaseRunner class. Refer here. This can generate junit style test result in xml file. Then you can use different approaches to transform xml to html using any of the following:

         

        • stylesheet
        • MarkupBuilder
        import com.eviware.soapui.tools.SoapUITestCaseRunner
        def runner = new SoapUITestCaseRunner()
        runner.with {
        //change the paths as needed to suit your environment
          setProjectFile('/path/to/Sample-soapui-project.xml')
        //Ignore below if you do not have any special settings.
          setSettingsFile('/path/to/soapui-settings.xml')
          setOutputFolder('/tmp/results')
          setPrintReport(true)
          setExportAll(true)
          setJUnitReport(true)
          run()
        }

         

         

        If you use ant, it would be simple and do not have to write stylesheet or MarkupBuilder. Use below link for more details.

        http://blog.infostretch.com/customizing-soapui-reports/

    • nmrao's avatar
      nmrao
      Champion Level 3
      You can find in the same above place i.e., "Message 5"
      • rupert_anderson's avatar
        rupert_anderson
        Valued Contributor

        Hi, 

         

        Thanks for the requirements, I see that you want to run the report at project level and that you have quite a large number of TestSuites / TestCases. Just to get the ball rolling I have created a really simple CSV report script that can be pasted into the TearDown Script tab at project level:

         

        log.info "TestSuite Name,TestSuite Status,TestCase Name,TestCase Status,Error Messages(s)"
        for ( testSuiteResult in runner.results ){
        	
        	for ( testCaseResult in testSuiteResult.results )
        	{
        		def row=""
        		row=testCaseResult.testCase.name + ","+testCaseResult.status.toString()+","
            		for ( testStepResult in testCaseResult.getResults() )
            		{
              		row+=testStepResult.testStep.name +","+ testStepResult.status.toString()+","
        			testStepResult.messages.each() { message -> row+=message
        			}
        		}
        		log.info row
        	}
        
        }

        In produces results like:

        Fri Sep 16 15:05:58 BST 2016:INFO:TestSuite Name,TestSuite Status,TestCase Name,TestCase Status,Error Messages(s)
        Fri Sep 16 15:05:58 BST 2016:INFO:TestCase,FAILED,REST Request,FAILED,org.apache.http.conn.HttpHostConnectException: Connection to http://localhost:9080 refused
        Fri Sep 16 15:05:58 BST 2016:INFO:TestCase 1,FAILED,REST Request To Update 1,FAILED,org.apache.http.conn.HttpHostConnectException: Connection to http://localhost:9080 refused
        

        Is this the type of data you're looking for?

         

        Next steps could be to:

        • Instead produce HTML output - I have some ideas on this.
        • Write the output to a file - this should be easy

        Note this is an alternative direction to nmrao s script, let me know if it doesn't suite your need. I am interested in developing a more self contained / integrated approach, possibly leading to a simple plugin.

         

        Let me know your thoughts,

        Thanks,

        Rupert