Itam_Media
15 years agoContributor
Issue with Customizing JUnit Reports when using Excel Dataso
I am running a testcase which loads data from an excel sheet and runs through them (using the DataSource Loop step). When we run this using maven, we want the Junit reports generated to not just say whether the testcase passed or failed, but actually give us the row information (from the excel spreadsheet) that passed or failed (also print the data and assertion from that row in excel ).
To achieve this, I wrote a custom JUnitReportCollector (and override the afterStep method)
My issue is this:
i) The afterStep gets called only once even though there are multiple rows of data in the excel spreadsheet. I would expect this to be called for every row of data. Is my understanding correct? Is there some other way I can do the acheive the same thing.
ii) To even get this far, I had to set the reportcollector (on my custom extension to SoapUIProTestCaseRunner) using reflection (because the reportcollector is a private field on SoapUIProTestCaseRunner ). Do you provide extension points for us to do this directly from the API.
Please contact me for any questions/information.
-- Sang
To achieve this, I wrote a custom JUnitReportCollector (and override the afterStep method)
public class ICJUnitReportCollector extends JUnitReportCollector
{
public void afterStep(TestCaseRunner testRunner, TestCaseRunContext runContext, TestStepResult result)
{
TestStep currentStep = result.getTestStep();
WsdlDataSourceTestStep wsdlDataSourceTestStep = null;
if (currentStep instanceof WsdlDataSourceTestStep){
wsdlDataSourceTestStep = (WsdlDataSourceTestStep) currentStep;
_currentRow = wsdlDataSourceTestStep.getCurrentRow();
SoapUI.log.info("Debug: wsdlDataSourceTestStep - current row " + _currentRow);
Map wsdlDataSourceTestStepProperties = wsdlDataSourceTestStep.getProperties();
Iterator iter = wsdlDataSourceTestStepProperties.entrySet().iterator();
while (iter.hasNext()){
Map.Entry entry = (Map.Entry) iter.next();
SoapUI.log.info("Debug: wsdlDataSourceTestStep - property name " + entry.getKey() + " with value " + ((TestStepProperty)entry.getValue()).getValue() );
}
}
\\\
}
}
My issue is this:
i) The afterStep gets called only once even though there are multiple rows of data in the excel spreadsheet. I would expect this to be called for every row of data. Is my understanding correct? Is there some other way I can do the acheive the same thing.
ii) To even get this far, I had to set the reportcollector (on my custom extension to SoapUIProTestCaseRunner) using reflection (because the reportcollector is a private field on SoapUIProTestCaseRunner ). Do you provide extension points for us to do this directly from the API.
Please contact me for any questions/information.
-- Sang