Slightly modified under implementation, using the Streamingmarkupbuilder method.
The layout of the generated XML is gone, but it's not, and it's not the end of the book, anyway.
ImportCom.eviware.soapui.SoapUI//log.info Runner.getid ()//def SW = new StringWriter ()//def XML = new Groovy.xml.MarkupBuilder (SW)def builder =NewGroovy.xml.StreamingMarkupBuilder () builder.encoding= "UTF-8"def Report= {//XMLmkp.xmldeclaration () Report (Type:"SoapUI", Version:SoapUI.SOAPUI_VERSION) {Passedcount=0Failedcount=0Warningscount=0runner.getresults (). Each{tsuite-//Log.info Tsuite.statusPassed=0failed=0Warnings=0tsuite.getresults (). status.each{//Log.info It if(it.tostring () = = "Finished") {passed=passed+1 } Else if(it.tostring () = = "FAILED") {failed=failed+1 } Else if(it.tostring () = = "WARNING") {Warnings=warnings+1 } } //log.info tsuite.getresults (). StatusTestSuite (Name:tsuite.testSuite.getName (), Status:tsuite.getStatus (), Runtime:tsuite.getTimeTaken ()/1000, Stime:tsuite.getStartTime (), passed:passed,failed:failed) {tsuite.getresults (). Each{tcase-passed=0failed=0Warnings=0tcase.getresults (). status.each{//Log.info It if(it.tostring () = = "OK") {passed=passed+1Passedcount=passedcount+1 } Else if(it.tostring () = = "FAILED") {failed=failed+1Failedcount=failedcount+1 } Else if(it.tostring () = = "WARNING") {Warnings=warnings+1Warningscount=warningscount+1}} TestCase (Name:tcase.testCase.getName (), Status:tcase.getStatus (), Runtime:tcase.getTimeTak En ()/1000, Stime:tcase.getStartTime (), passed:passed,failed:failed,warnings:warnings) {tcase.getresults (). Each{tstep-Teststep (Name:tstep.testStep.getName (), Status:tstep.getStatus (), Runtime:tstep.getTimeTaken ()/1000) {tstep.getmessages (). Each{message-Message () {mkp.yieldunescaped"<! [Cdata[${message.tostring ()}]]> "}} requestheaders () {//Mkp.yieldunescaped "<! [Cdata[${tstep.getrequestheaders ()}]]> " } } //log.info tstep.getresults () } } } } //}} Summary (Name:project.name,stime:project.getpropertyvalue ("Stime"), ETime:NewDate (). Format (' Yyyy-mm-dd HH:mm:ss '), Status:runner.getStatus (), Runtime:runner.getTimeTaken ()/1000, Passed:passedcount,failed:failedcount,warnings:warningscount)}}//Log.info SWdef writer=NewFileWriter ("/users/zhangminjie/${project.name}-${new Date (). Format (' Yymmddhhmmss ')}.xml") Writer<<builder.bind (report)//new File ("/users/zhangminjie/soapuireport.xml"). Write (Sw.tostring ())
SOAPUI Open source version simple custom report 2