Forum Discussion

SNeves_Barros's avatar
13 years ago

DataSink SubReport

Hello,

I have added a DataSink SubReport with no problem to TestCaseReport.jrxml. You can see the code in TestCaseReport.jrxml below:


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


and subreport testSubReport code below:

<jasperReport xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="report name" language="groovy" pageWidth="535" pageHeight="842" 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="testNamePrint" class="java.lang.String"/>
<columnHeader>
<band height="59">
<staticText>
<reportElement style="ColumnHeader" x="0" y="35" width="535" height="20"/>
<textElement textAlignment="Left" verticalAlignment="Middle"/>
<text>Tests Run from Data Driven .csv File</text>
</staticText>
</band>
</columnHeader>
<detail>
<band height="21">
<textField>
<reportElement x="0" y="1" width="535" height="20"/>
<textElement textAlignment="Left" verticalAlignment="Top"/>
<textFieldExpression class="java.lang.String">$F{testNamePrint}</textFieldExpression>
</textField>
</band>
</detail>
</jasperReport>


After that I am able to set up a DataSink test step and select subreport and I will have the testNamePrint column of dataSink print on my TestCaseReport.

The problem comes when I try to add the same subreport to TestCaseResultsReport.jrxml in order to have the same in the report when a generate it from TestSuiteReport that has TestCaseResultsReport as a subreport.

I am adding the same subreport code (1st posted here) to TestCaseResultsReport.jrxml but it is not working. I guess that it is because of dataSourceExpresion field.

Any solution or comments to help with this issue.

Thanks in advance.