Forum Discussion

cbyndr's avatar
cbyndr
Contributor
15 years ago

how to generate coverage reports via groovy script

Is there some way to generate and then save coverage report data for test cases or test suites from groovy? This would really enhance how we use soapui for our continuous integration testing.

2 Replies

  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    Hello,

    Here is an example..



    import com.eviware.soapui.reporting.ReportEngineRegistry
    import com.eviware.soapui.reporting.reports.testcase.*

    def report = new WsdlTestCaseReport(context.testCase)
    def availableReports = ReportEngineRegistry.getAvailableReports( report  ) // get list of all reports for test case

    // generate 2nd , format PDF ( here you can add other formats ), at location "/home/robert/Documents/soapui-projects"
    availableReports[1].generate( report.getModelItem().getSettings(), (String[])[ "PDF" ], "/home/robert/Documents/soapui-projects" )
    availableReports[1].release()



    this is to enable coverage from groovy( before run test case ) :



    import com.eviware.soapui.impl.coverage.report.CoverageBuilder

    context.testCase.addTestRunListener( new CoverageBuilder() )



    Let me know does it helps,
    robert
  • Thank you very much, I have played around with this some and it's definitely a step in the right direction, as I can create report for an individual test.

    But, none of the operations tested in this test case show up as covered in the report. Every item reads 0/125, 0/6 etc. etc.

    Could this be related to the error I get from the availableReports[1].release() bit of code? That gives me this error:

    groovy.lang.MissingMethodException: No signature of method: com.eviware.soapui.reporting.engine.junit.GeneratableJUnitReport.release() is applicable for argument types: () values: []