private void generateTCBasedData(List<TestCaseResult> allTestsList) {
        logger.entering(allTestsList);
        SummarizedData tempClass;
        SummarizedData tempGroupClass;
        Map<String, SummarizedData> mpClassData = new HashMap<String, SummarizedData>();
        int outputSheetRowCounter = 3;

        for (TestCaseResult tcResult : allTestsList) {

            // Segregating for class data
            String sTempClassName = tcResult.getClassName();

            // If class not already added to Class data, then create new ClassObject exists
            if (!mpClassData.containsKey(sTempClassName)) {
                tempClass = new SummarizedData();
                tempClass.setsName(sTempClassName);

            } else {
                tempClass = mpClassData.get(sTempClassName);
            }

            // Adding test to total count
            tempClass.incrementiTotal();

            // Adding all groups to map
            for (String sGroup : tcResult.getGroup()) {

                // Forming a key for the GroupClass map which is <GroupName><ClassName>
                String sGroupClassName = sGroup + sTempClassName;
                if (!mpGroupClassData.containsKey(sGroupClassName)) {
                    tempGroupClass = new SummarizedData();
                    tempGroupClass.setsName(sTempClassName);
                } else {
                    tempGroupClass = mpGroupClassData.get(sGroupClassName);
                }

                tempGroupClass.incrementiTotal();
                tempGroupClass.incrementCount(tcResult.getStatus());
                tempGroupClass.incrementDuration(tcResult.getDurationTaken());
                mpGroupClassData.put(sGroupClassName, tempGroupClass);
            }

            // Segregating for detailed Testcase Status wise data
            List<String> str = new ArrayList<String>();
            str.add(tcResult.getClassName());
            str.add(tcResult.getMethodName());
            str.add(tcResult.getTestDesc());
            str.add(tcResult.getGroup().toString());
            str.add(String.valueOf(tcResult.getDurationTaken()));
            str.add("'" + ReportSheetNames.TESTOUTPUTDETAILSREPORT.getName() + "'!B"
                    + Integer.toString(outputSheetRowCounter));

            List<String> outputStr = new ArrayList<String>();
            outputStr.add("Class Name:" + tcResult.getClassName());
            outputStr.add("Method/Testcase id:" + tcResult.getMethodName());
            outputStr.addAll(tcResult.getssmsg());

            // Based on status, incrementing class count and adding str to correct
            // list for TC detailed report
            switch (tcResult.getStatus()) {
                case ITestResult.FAILURE: {
                    tcFailedData.add(str);
                    // For failed cases adding data for defect description sheet
                    for (int iErrorCount = 0; iErrorCount < tcResult.getError().size(); iErrorCount++) {
                        List<String> tmpList = new ArrayList<String>();
                        tmpList.addAll(0, str);
                        tmpList.add(tcResult.getDefect().get(iErrorCount));
                        tmpList.add(tcResult.getError().get(iErrorCount));
                        outputStr.add("Stacktrace:" + tcResult.getError().get(iErrorCount));
                        tcDefectData.add(tmpList);
                    }
                    break;
                }
                case ITestResult.SUCCESS: {
                    tcPassedData.add(str);
                    break;
                }
                case ITestResult.SKIP: {
                    tcSkippedData.add(str);
                    break;
                }
                default: {
                    break;
                }
            }
            tcOutputData.add(outputStr);
            outputSheetRowCounter = outputSheetRowCounter + 1 + outputStr.size();

            tempClass.incrementCount(tcResult.getStatus());
            // Add to the total runtime of the class
            tempClass.setlRuntime(tempClass.getlRuntime() + tcResult.getDurationTaken());
            mpClassData.put(sTempClassName, tempClass);
        }
        lClasses.addAll(mpClassData.values());
        Collections.sort(lClasses);
        logger.exiting();
    }
private void generateTCBasedData ( List < TestCaseResult > allTestsList ) { logger . entering ( allTestsList ) ; SummarizedData tempClass ; SummarizedData tempGroupClass ; Map < String , SummarizedData > mpClassData = new HashMap < String , SummarizedData > ( ) ; int outputSheetRowCounter = 3 ; for ( TestCaseResult tcResult : allTestsList ) { String sTempClassName = tcResult . getClassName ( ) ; if ( ! mpClassData . containsKey ( sTempClassName ) ) { tempClass = new SummarizedData ( ) ; tempClass . setsName ( sTempClassName ) ; } else { tempClass = mpClassData . get ( sTempClassName ) ; } tempClass . incrementiTotal ( ) ; for ( String sGroup : tcResult . getGroup ( ) ) { String sGroupClassName = sGroup + sTempClassName ; if ( ! mpGroupClassData . containsKey ( sGroupClassName ) ) { tempGroupClass = new SummarizedData ( ) ; tempGroupClass . setsName ( sTempClassName ) ; } else { tempGroupClass = mpGroupClassData . get ( sGroupClassName ) ; } tempGroupClass . incrementiTotal ( ) ; tempGroupClass . incrementCount ( tcResult . getStatus ( ) ) ; tempGroupClass . incrementDuration ( tcResult . getDurationTaken ( ) ) ; mpGroupClassData . put ( sGroupClassName , tempGroupClass ) ; } List < String > str = new ArrayList < String > ( ) ; str . add ( tcResult . getClassName ( ) ) ; str . add ( tcResult . getMethodName ( ) ) ; str . add ( tcResult . getTestDesc ( ) ) ; str . add ( tcResult . getGroup ( ) . toString ( ) ) ; str . add ( String . valueOf ( tcResult . getDurationTaken ( ) ) ) ; str . add ( "'" + ReportSheetNames . TESTOUTPUTDETAILSREPORT . getName ( ) + "'!B" + Integer . toString ( outputSheetRowCounter ) ) ; List < String > outputStr = new ArrayList < String > ( ) ; outputStr . add ( "Class Name:" + tcResult . getClassName ( ) ) ; outputStr . add ( "Method/Testcase id:" + tcResult . getMethodName ( ) ) ; outputStr . addAll ( tcResult . getssmsg ( ) ) ; switch ( tcResult . getStatus ( ) ) { case ITestResult . FAILURE : { tcFailedData . add ( str ) ; for ( int iErrorCount = 0 ; iErrorCount < tcResult . getError ( ) . size ( ) ; iErrorCount ++ ) { List < String > tmpList = new ArrayList < String > ( ) ; tmpList . addAll ( 0 , str ) ; tmpList . add ( tcResult . getDefect ( ) . get ( iErrorCount ) ) ; tmpList . add ( tcResult . getError ( ) . get ( iErrorCount ) ) ; outputStr . add ( "Stacktrace:" + tcResult . getError ( ) . get ( iErrorCount ) ) ; tcDefectData . add ( tmpList ) ; } break ; } case ITestResult . SUCCESS : { tcPassedData . add ( str ) ; break ; } case ITestResult . SKIP : { tcSkippedData . add ( str ) ; break ; } default : { break ; } } tcOutputData . add ( outputStr ) ; outputSheetRowCounter = outputSheetRowCounter + 1 + outputStr . size ( ) ; tempClass . incrementCount ( tcResult . getStatus ( ) ) ; tempClass . setlRuntime ( tempClass . getlRuntime ( ) + tcResult . getDurationTaken ( ) ) ; mpClassData . put ( sTempClassName , tempClass ) ; } lClasses . addAll ( mpClassData . values ( ) ) ; Collections . sort ( lClasses ) ; logger . exiting ( ) ; }
Generates class based summary and the basis for Detailed group-wise summary report