Beispiel #1
0
 public bool ExportData(TestSummary testSummaryCollection,
                        UnitTestResultCollection unitTestResultCollection,
                        string fileName,bool isIncludeOutput)
 {
     GenerateReport(unitTestResultCollection, testSummaryCollection, fileName, isIncludeOutput);
     return true;
 }
Beispiel #2
0
        private static void GenerateReport(UnitTestResultCollection unitTestResultCollection,
                                           TestSummary testSummaryCollection, string fileName, bool isIncludeOutput)
        {
            var file = new System.IO.FileInfo(fileName);
            if (file.Exists)
                file.Delete();
            using (var p = new ExcelPackage(file))
            {
                //set the workbook properties and add a default sheet in it
                SetWorkbookProperties(p);
                //Create a sheet
                ExcelWorksheet ws = CreateSheet(p, unitTestResultCollection.CollectionName);
                DataTable dt = CommonUtilities.CreateDataTable(unitTestResultCollection, isIncludeOutput);

                ////Merging cells and create a center heading for out table
                ws.Cells[1, 1].Value = "Trx2Any - Trx to Excel Export";
                ws.Cells[1, 1, 1, dt.Columns.Count].Merge = true;
                ws.Cells[1, 1, 1, dt.Columns.Count].Style.Font.Bold = true;
                ws.Cells[1, 1, 1, dt.Columns.Count].Style.HorizontalAlignment = ExcelHorizontalAlignment.Center;

                int rowIndex = 2;

                //Create Summary Table
                CreateSummaryHeaders(ws, ref rowIndex, dt.Columns.Count, testSummaryCollection);

                CreateHeader(ws, ref rowIndex, dt);
                CreateData(ws, ref rowIndex, dt);

                ws.Column(dt.Columns.Count).Width = 100;
                p.Save();
            }
        }
Beispiel #3
0
        private static void CreateSummaryHeaders(ExcelWorksheet ws, ref int rowIndex, int testResultColumnCount,
                                                 TestSummary collection)
        {
            ws.Cells[rowIndex, 1].Value = "Summary";
            ws.Cells[rowIndex, 1, rowIndex, testResultColumnCount].Merge = true;
            ws.Cells[rowIndex, 1, rowIndex, testResultColumnCount].Style.Font.Bold = true;
            ws.Cells[rowIndex, 1, rowIndex, testResultColumnCount].Style.HorizontalAlignment =
                ExcelHorizontalAlignment.Center;
            rowIndex++;

            ws.Cells[rowIndex, 1].Value = "TotalTestCaseRun";
            ws.Cells[rowIndex, 2].Value = "Passed";
            ws.Cells[rowIndex, 3].Value = "Failed";
            ws.Cells[rowIndex, 4].Value = "Inconclusive";

            rowIndex++;

            ws.Cells[rowIndex, 1].Value = collection.TotalTestCaseRun;
            ws.Cells[rowIndex, 2].Value = collection.Passed;
            ws.Cells[rowIndex, 3].Value = collection.Failed;
            ws.Cells[rowIndex, 4].Value = collection.Inconclusive;

            rowIndex++;
        }