Forum Discussion

iano's avatar
iano
New Contributor
9 years ago

TestCaseResultsReport: How to show only the failed test cases

This is my first time posting, so if my post is wrong, my apologies.

I am not that adept in scripting, so I gave up on me figuring out on customizing the reports.

 

I created a Subreport and mimicking the TestCaseResultsReport.

I just want to know, how do make it that it will only return the Failed Test Cases?

 

Here's an example of the script. Again I am just getting what's with the current TestCaseResultsReport Subreports and removing certain fields that I don't need. The last hurdle is just to show Failed Test Cases and the error details.

<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>
   <style name="statusStyle" isDefault="false">
      <conditionalStyle>
         <conditionExpression>Boolean.valueOf($F{status}.equals( "UNKNOWN" ))</conditionExpression>
         <style isDefault="false" style="statusStyle" mode="Opaque" backcolor="#FFFF00"/>
      </conditionalStyle>
      <conditionalStyle>
         <conditionExpression>Boolean.valueOf($F{status}.equals( "FINISHED" ))</conditionExpression>
         <style isDefault="false" style="statusStyle" mode="Opaque" backcolor="#66FF00"/>
      </conditionalStyle>
      <conditionalStyle>
         <conditionExpression>Boolean.valueOf($F{status}.equals( "FAILED" ))</conditionExpression>
         <style isDefault="false" style="statusStyle" mode="Opaque" forecolor="#FFFF00" backcolor="#FF3333" isBold="true"/>
      </conditionalStyle>
   </style>
   <parameter name="FlowLayout" class="java.lang.Boolean"/>
   <parameter name="ErrorDetails" class="java.lang.Boolean"/>
   <field name="startTime" class="java.lang.String"/>
   <field name="timeTaken" class="java.lang.String"/>
   <field name="status" class="java.lang.String"/>
   <field name="testCaseName" class="java.lang.String"/>
   <field name="reason" class="java.lang.String"/>
   <field name="testStepResults" class="net.sf.jasperreports.engine.JRDataSource"/>
   <field name="testProperties" class="net.sf.jasperreports.engine.JRDataSource"/>
   <field name="failedTestSteps" class="net.sf.jasperreports.engine.JRDataSource"/>
   <detail>
      <band height="201">
         <break>
            <reportElement x="0" y="1" width="100" height="1">
               <printWhenExpression>!$P{FlowLayout}</printWhenExpression>
            </reportElement>
         </break>
         <textField>
            <reportElement style="SmallHeader" mode="Opaque" x="0" y="2" width="535" height="32" forecolor="#000000" backcolor="#FFFFFF"/>
            <box leftPadding="0"/>
            <textElement/>
            <textFieldExpression class="java.lang.String">$F{testCaseName}</textFieldExpression>
         </textField>
         <textField>
            <reportElement style="statusStyle" x="0" y="65" width="71" height="15"/>
            <box topPadding="1" leftPadding="1" bottomPadding="1" rightPadding="1"/>
            <textElement verticalAlignment="Top"/>
            <textFieldExpression class="java.lang.String">$F{status}</textFieldExpression>
         </textField>
         <textField>
            <reportElement mode="Transparent" x="81" y="66" width="109" height="18" backcolor="#FFFFFF"/>
            <box leftPadding="2"/>
            <textElement verticalAlignment="Top"/>
            <textFieldExpression class="java.lang.String">$F{startTime}</textFieldExpression>
         </textField>
         <textField>
            <reportElement mode="Transparent" x="190" y="67" width="87" height="14" backcolor="#FFFFFF"/>
            <textElement verticalAlignment="Top"/>
            <textFieldExpression class="java.lang.String">$F{timeTaken}.concat( " ms" )</textFieldExpression>
         </textField>
         <textField isStretchWithOverflow="true" isBlankWhenNull="true">
            <reportElement mode="Transparent" x="277" y="67" width="258" height="14" backcolor="#FFFFFF"/>
            <textElement verticalAlignment="Top"/>
            <textFieldExpression class="java.lang.String">$F{reason}</textFieldExpression>
         </textField>
         <subreport isUsingCache="false">
            <reportElement positionType="Float" isPrintRepeatedValues="false" x="0" y="119" width="535" height="40" isRemoveLineWhenBlank="true"/>
            <subreportParameter name="FlowLayout">
               <subreportParameterExpression>$P{FlowLayout}</subreportParameterExpression>
            </subreportParameter>
            <subreportParameter name="testCaseName">
               <subreportParameterExpression>$F{testCaseName}</subreportParameterExpression>
            </subreportParameter>
            <dataSourceExpression>$F{testStepResults}</dataSourceExpression>
            <subreportExpression class="java.lang.String">"subreport:TestStepResultsReport"</subreportExpression>
         </subreport>
         <staticText>
            <reportElement style="ColumnHeader" x="0" y="40" width="81" height="20"/>
            <textElement/>
            <text>Status</text>
         </staticText>
         <staticText>
            <reportElement style="ColumnHeader" x="81" y="40" width="109" height="20"/>
            <textElement/>
            <text>Start Time</text>
         </staticText>
         <staticText>
            <reportElement style="ColumnHeader" x="190" y="40" width="87" height="20"/>
            <textElement/>
            <text>Time Taken</text>
         </staticText>
         <staticText>
            <reportElement style="ColumnHeader" x="277" y="40" width="258" height="20"/>
            <textElement/>
            <text>Reason</text>
         </staticText>
      </band>
   </detail>
</jasperReport>

P.S. I am also new at using SOAPUI, just trying to learn and I'm currently studying it

No RepliesBe the first to reply