Beispiel #1
0
        public static DataTable CreateDataTable(UnitTestResultCollection collection,bool isIncludeOutput)
        {
            var dt = new DataTable();

            dt.Columns.Add("TestName");
            dt.Columns.Add("TestCategory");
            dt.Columns.Add("TestStatus");
            dt.Columns.Add("TestRun");
            dt.Columns.Add("TestCaseDescription");
            if (isIncludeOutput)
            {
                dt.Columns.Add("ErrorInformation");
                dt.Columns.Add("StandardOutput");
            }

            foreach (var t in collection)
            {
                var dr = dt.NewRow();
                dr["TestName"] = t.TestName;
                dr["TestCategory"] = t.TestCaseDescription;
                dr["TestStatus"] = t.TestStatus;
                dr["TestRun"] = t.TestRun;
                dr["TestCaseDescription"] = t.TestCaseDescription;
                if (isIncludeOutput)
                {
                    dr["ErrorInformation"] = t.ErrorInformation;
                    dr["StandardOutput"] = t.StandardOutput;
                }
                dt.Rows.Add(dr);
            }

            return dt;
        }
Beispiel #2
0
 public bool ExportData(TestSummary testSummaryCollection,
                        UnitTestResultCollection unitTestResultCollection,
                        string fileName, bool isIncludeOutput)
 {
     GenerateReport(unitTestResultCollection, testSummaryCollection, fileName, isIncludeOutput);
     return(true);
 }
Beispiel #3
0
        /// <summary>
        /// Creates the data table with some dummy data.
        /// </summary>
        /// <returns>DataTable</returns>
        private static DataTable CreateDataTable(UnitTestResultCollection collection)
        {
            var dt = new DataTable();

            dt.Columns.Add("TestName");
            dt.Columns.Add("TestCategory");
            dt.Columns.Add("TestStatus");
            dt.Columns.Add("TestRun");
            dt.Columns.Add("TestCaseDescription");
            dt.Columns.Add("ErrorInformation");
            dt.Columns.Add("StandardOutput");

            foreach (var t in collection)
            {
                var dr = dt.NewRow();
                dr["TestName"]            = t.TestName;
                dr["TestCategory"]        = t.TestCaseDescription;
                dr["TestStatus"]          = t.TestStatus;
                dr["TestRun"]             = t.TestRun;
                dr["TestCaseDescription"] = t.TestCaseDescription;
                dr["ErrorInformation"]    = t.ErrorInformation;
                dr["StandardOutput"]      = t.StandardOutput;

                dt.Rows.Add(dr);
            }

            return(dt);
        }
Beispiel #4
0
 public bool ExportData(TestSummary testSummaryCollection,
                        UnitTestResultCollection unitTestResultCollection,
                        string fileName,bool isIncludeOutput)
 {
     GenerateReport(unitTestResultCollection, testSummaryCollection, fileName, isIncludeOutput);
     return true;
 }
Beispiel #5
0
        public MSTest2010Trx([Import("ParsedFilePath")]string trxPath)
        {
            var trxFileName = new FileInfo(trxPath);
            _unitTestResultCollection
                                        = new UnitTestResultCollection(trxFileName.Name);

            PrepareTestCollection(trxFileName);
        }
Beispiel #6
0
 public TestSummary(UnitTestResultCollection results)
 {
     totalTestCaseRun = results.Count;
     passed = results.Where(x => x.TestStatus.Equals("passed", StringComparison.OrdinalIgnoreCase)).Count();
     failed = results.Where(x => x.TestStatus.Equals("failed", StringComparison.OrdinalIgnoreCase)).Count();
     inconclusive = totalTestCaseRun - passed - failed;
     passPercentage = passed / totalTestCaseRun * 100;
 }
Beispiel #7
0
        public MSTest2010Trx([Import("ParsedFilePath")] string trxPath)
        {
            var trxFileName = new FileInfo(trxPath);

            _unitTestResultCollection
                = new UnitTestResultCollection(trxFileName.Name);

            PrepareTestCollection(trxFileName);
        }
Beispiel #8
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 Document())
            {
                //set the workbook properties and add a default sheet in it
                PdfWriter.GetInstance(p, new FileStream(fileName, FileMode.Create));
                SetWorkbookProperties(p);
                ////Create a sheet
                p.Open();
                p.AddTitle(unitTestResultCollection.CollectionName.ToString() + " - Test Report");
                p.Add(new Paragraph(unitTestResultCollection.CollectionName + " - Trx2Any Report"));
                BaseFont bfTimes = BaseFont.CreateFont(BaseFont.TIMES_ROMAN, BaseFont.CP1252, false);
                var      times   = new iTextSharp.text.Font(bfTimes, 8, iTextSharp.text.Font.ITALIC, iTextSharp.text.BaseColor.RED);
                p.Add(new Paragraph("This is a report generated by trx2any", times));


                //ExcelWorksheet ws = CreateSheet(p, unitTestResultCollection.CollectionName);
                DataTable dt = CommonUtilities.CreateDataTable(unitTestResultCollection, isIncludeOutput);


                //Create Summary Table
                CreateSummaryHeaders(p, testSummaryCollection);

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

                //ws.Column(dt.Columns.Count).Width = 100;
                //p.Save();
                p.Close();
            }
        }
Beispiel #9
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 #10
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();
            }
        }