Forum Discussion

JGibson's avatar
JGibson
Occasional Contributor
12 years ago

Custom Report for TestSuite with DataSink

I'm looking for some help generating a custom report when generating a TestSuite Report, and including information from DataSink's that are in each TestCase. I have successfully been able to gener...
  • PM_r's avatar
    12 years ago
    This is quite cumbersome to do, and not a out-of-the-box supported solution. Anyway, here goes:

    1. Create your own TestSuite report template (which you've already done) and add a parameter for the DataSink in the parameter section on the top, e.g:
    <parameter name="DataSink" class="net.sf.jasperreports.engine.JRDataSource"/>


    2. Create your own sub report template, in line with the DataSink (which you've already done) and refer to this in the TestSuite report template mentioned above – put ${<name on the above-defined parameter>} as DataSourceExpression, e.g:

           <subreport isUsingCache="true">
    <reportElement positionType="Float" isPrintRepeatedValues="false" x="1" y="1" width="535" height="30" isRemoveLineWhenBlank="true"/>
    <dataSourceExpression>$P{DataSink}</dataSourceExpression>
    <subreportExpression class="java.lang.String">"subreport:TestDataSinkSubReport"</subreportExpression>
    </subreport>


    3. Enter the following script in the Report Script tab for the TestSuite:

    import com.eviware.soapui.reporting.reports.support.ExportableJRTableModelDataSource
    import com.eviware.soapui.reporting.reports.support.TableModelWrapper

    if( params[""<name of the parameter that was defined in step 1 above>"] == null )
    {
    def testStep = testSuite.testCases["<name of testcase that contains the DataSink TestStep that you want to show in the report>"].testSteps["<name of the actual DataSink TestStep>"]
    params["<name of the parameter that was defined in step 1 above>"]= new ExportableJRTableModelDataSource( new TableModelWrapper( testStep.dataSink.data ), "items", "item" );
    }


    This script "exposes" the DataSink to the report in a format that it understands. If you have several DataSinks that you want to export in the reports, you simply have to define the corresponding parameters and put them in params with a corresponding script.

    Hope this works for you!

    Henrik O
    SmartBear Software