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 generate custom reports for TestCase's that take information from a DataSink, using the DataSink Reporting Tutorial (http://www.soapui.org/Reporting/using-t ... asink.html).

I have been unable to customize a TestSuite report that includes information from the TestCases DataSinks.

What are the 'magic' bits of code that need to be included in the report and subreport code?
  • 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

10 Replies

  • 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
    • sas's avatar
      sas
      Occasional Contributor

      I have a similar requirement but I need to reference the Datasink Teststep data of a specific testsuit, testcase at the project level report. 

      Please, can you tell me how can I do that?

      I tried the above code but does not work.

       

      Thanks

  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    Hi JGibson,

    As we said before, what you are trying to achieve is possible but not readily available out-of-the-box.
    We believe our documentation on reports is enough to cover a large number of different user cases.
    However, we are never going to be able to cover every possible case.
    I believe that the best we can do at this stage is to provide you with a few links which may help you find out yourself how to resolve this issue.

    SoapUI's reporting infrastructure is described here:

    http://www.soapui.org/Reporting/reporti ... cture.html

    As mentioned there, we just use Jasper Reports under the hood, so for more advanced capabilities, please check out the Jasper documentation:

    http://community.jaspersoft.com/wiki/ja ... y-tutorial

    Best regards,

    Renato Athaydes
    SmartBear Software
  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    In order to help you, could you please be more specific about what you are trying to achieve and what you have already tried which did not work?

    Regards,

    Renato Athaydes
    SmartBear Sweden
  • JGibson's avatar
    JGibson
    Occasional Contributor
    TestCase
    In each of our TestCases we have placed a DataSink (Report Data) that is placed directly after a SOAP TestRequest.
    The DataSink grabs two values:
    a) the one value is from a DataSource, taking a value from the current Excel column, 'Test Name'.
    b) the second value is taken from a SOAP TestRequest, which is the 'Status' after the TestRequest is executed.
    Then when we generate the report for a TestCase, we place this data at the end as a summary of the tests that were done. We are successfully able able to create a report based on the tutorials.

    TestSuite
    I have been attempting to follow the same methodology that the TestCaseResultsReport subreport uses. In the TestCaseResultsReport subreport, there a section that calls another subreport. This creates a summary of the TestStep Results for each of the TestCase's in the TestSuite.

    I have reduced the bits of code down to as simple as possible for testing purposes. Below is the working code I am using as the basis of my testing, which displays the TestStep Results for each TestCase.

    Custom TestSuite Report
    <jasperReport xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="TestSuiteReport" language="groovy" pageWidth="595" pageHeight="842" whenNoDataType="AllSectionsNoDetail" columnWidth="535" leftMargin="30" rightMargin="30" topMargin="30" bottomMargin="30" isSummaryNewPage="true" xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <property name="ireport.encoding" value="UTF-8"/>
    <template>"../../styles.jrtx"</template>
    <detail>
    <band height="233">
    <subreport isUsingCache="false">
    <reportElement positionType="Float" isPrintRepeatedValues="false" x="1" y="0" width="535" height="32" isRemoveLineWhenBlank="true">
    </reportElement>
    <dataSourceExpression>$P{TestSuiteTestCaseResults}.cloneDataSource()</dataSourceExpression>
    <subreportExpression class="java.lang.String">"subreport:CustomTestCaseResultsReport02"</subreportExpression>
    </subreport>
    </band>
    </detail>
    </jasperReport>


    CustomTestCaseResultsReport02
    <jasperReport xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="TestCaseResultsReport" language="groovy" pageWidth="535" pageHeight="842" whenNoDataType="AllSectionsNoDetail" columnWidth="535" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <template>"../../styles.jrtx"</template>
    <field name="testStepResults" class="net.sf.jasperreports.engine.JRDataSource"/>
    <detail>
    <band height="201">
    <subreport isUsingCache="false">
    <reportElement positionType="Float" isPrintRepeatedValues="false" x="0" y="2" width="535" height="40" isRemoveLineWhenBlank="true"/>
    <dataSourceExpression>$F{testStepResults}</dataSourceExpression>
    <subreportExpression class="java.lang.String">"subreport:TestStepResultsReport"</subreportExpression>
    </subreport>
    </band>
    </detail>
    </jasperReport>


    I have been attempting to modify the above code to reference the Datasinks.
    In the subreport, CustomTestCaseResultsReport02, I have tried the following:
    (a) Added a line trying to reference the DataSink: <field name="Report Data" class="net.sf.jasperreports.engine.JRDataSource"/>
    Result: Did not work

    (b) Tried using: <dataSourceExpression>$F{Report Data}</dataSourceExpression>, and commenting out the line after that: "<subreportExpression class ..."
    Also tried using $P{Report Data}. Both $F and $P did not work.

    My question is, how do I properly create a data source reference to my DataSinks, which are all named "Report Data"?
  • JGibson's avatar
    JGibson
    Occasional Contributor
    Perhaps the current tutorial could be expanded to include an example using DataSinks and a TestSuite report?
  • Hang on there, I'm looking at this!

    Henrik O
    SmartBear
  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    Hi there,

    just checking - did you get this working as required?

    Let us know so we can help if needed!

    regards,

    /Ole
    SmartBear Software
  • JGibson's avatar
    JGibson
    Occasional Contributor
    I believe we've had a misunderstanding. I'm having trouble calling subreports from within higher-level reports. I have managed to get a TestCase subreport to display correctly inside a TEstCase report, but I have not managed a TestCase subreport inside a TestSuite Report. I'm basically not very clear on what is required to make that connection in the two cases. I also don't feel I really understand how I would have to change the way I call subreports for different types of subreport datasources. For example, one of my subreports says its Data Source is "<unknown>", which works with my DataSinks, but the one that says "Data Sink" does not.

    I'm thinking my problem might be one of finding the right documentation. Is there a comprehensive reporting reference? The website only seems to have an example or two.