Exemplo n.º 1
0
        public GetDefectWithTestCaseCount(Properties props)
        {
            _project      = props.Project;
            _fileLocation = props.SaveLocation;
            _testPlanId   = props.TestPlanId;
            _testSuite    = props.TestSuiteId;

            _logger = props.Logger;
            HttpClientInitiator clientInitator = new HttpClientInitiator(props.Uri, props.PersonalAccessToken);

            _client = clientInitator.CreateHttpClient();
            _client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));

            _testCaseIdToResults = new Dictionary <int, List <TestCaseResult> >();

            _tfsCommonFunctions = new TFSCommonFunctions(props);

            if (props.UseWebApi == 1)
            {
                _allTestCaseId = GetTestCasesWebApi.GetAllTestCaseIds().Result;
            }
            else
            {
                GetTestCasesInSuite getTestCaseInSuite = new GetTestCasesInSuite(props);
                List <TestCase>     allTestCases       = getTestCaseInSuite.GatherTestCases();
                _allTestCaseId = new List <int>();
                foreach (TestCase currTestCase in allTestCases)
                {
                    _allTestCaseId.Add(currTestCase.TestCaseId);
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Get Test Cases directly from Web API and assign the testCaseRuns/Results to the correct test case.
        /// </summary>
        /// <param name="planId"></param>
        /// <param name=""></param>
        /// <returns></returns>
        private async Task <List <TestCase> > GetListOfTestCaseFromPlanId(int planId, List <TestRun> testRuns)
        {
            List <TestCase> res = new List <TestCase>();

            List <TestCase> tempTestCases = new List <TestCase>();

            tempTestCases = GetTestCasesWebApi.GetTestCaseByPlan(planId).Result;

            res = tempTestCases;

            //foreach (TestCase currTestCase in tempTestCases)
            //{
            //    TestCase testCaseCopy = currTestCase.CloneJson<TestCase>();

            //    try
            //    {
            //        if (_testCaseIdToResults.ContainsKey(testCaseCopy.TestCaseId))
            //        {
            //            testCase.TestCaseResults = _testCaseIdToResults[testCaseId];
            //        }

            //        if (tempTestCase != null)
            //        {
            //            testCases.Add(testCase);
            //        }
            //    }
            //    catch (Exception ex)
            //    {
            //        continue;
            //    }
            //}

            return(res);
        }
Exemplo n.º 3
0
        private int GetPathCumulativeHelper(DateTime date, string[] category, string path)
        {
            int res = GetTestCasesWebApi.GetTestCaseExecutedCumulativeAndPathAndStatuses(date,
                                                                                         category,
                                                                                         path).Result.Count;

            return(res);
        }
 public void UpdateSheet()
 {
     foreach (KeyValuePair <int, string> curr in _rowToTestCasePathMapping)
     {
         List <TestCase> testCasesFailedWithMinorDefect = GetTestCasesWebApi.GetTestCaseFailedWithMinorDefect(curr.Value).Result;
         //Console.WriteLine(curr.Value + ": " + testCasesFailedWithMinorDefect.Count);
         // Count of Test Cases that are Ready For Test with a Medium/Low defect and are in Failed status only.
         string formula = "-COUNTIFS(" + _props.ReadyForTestMediumLowSheetName + @"!D: D, 
                             'Folder Counts'!F" + curr.Key + ", "
                          + _props.ReadyForTestMediumLowSheetName + "!C: C, \"Failed\")";
         _excelWorksheet.Cells[curr.Key, 11].Formula = testCasesFailedWithMinorDefect.Count + "-N" + curr.Key;
     }
 }
Exemplo n.º 5
0
        public void UpdateExcelDefectWithTestCaseCount()
        {
            //GetTestCasesWebApi getTestCasesWebApi = new GetTestCasesWebApi();
            //List<int> _allTestCaseIds = getTestCasesWebApi.GetAllTestCaseIds().Result;

            DateTime earliestTime = new DateTime(2019, 4, 1);

            GetDefectWithTestCaseCount getDefectWithTestCaseCount = new GetDefectWithTestCaseCount(_props);
            List <Defect> res = getDefectWithTestCaseCount.DefectTestCaseCountTFS(earliestTime);

            Console.WriteLine("BreakPoint");

            if (_props.UseWebApi == 1)
            {
                Console.Write("Writing Defects to DB... ");
                PostHelper <Defect>(res, "/api/Defect");
                Console.WriteLine();
                Console.WriteLine("Finished writing Defects to DB...");
            }
            else
            {
                Console.Write("Not using WebAPI. Not writing to DB... ");
            }

            List <TestCase> allTestCaseInSuite;

            if (_props.UseWebApi == 1)
            {
                allTestCaseInSuite = GetTestCasesWebApi.GetAllTestCases().Result;
            }
            else
            {
                GetTestCasesInSuite getTestCasesInSuite = new GetTestCasesInSuite(_props);
                allTestCaseInSuite = getTestCasesInSuite.GatherTestCases();
            }

            List <Defect> defectsFromTFS = GetDefectWebApi.GetDefects().Result;

            UpdateDefectWithTestCaseCount updateDefectWithTestCaseCount = new UpdateDefectWithTestCaseCount(_props);

            updateDefectWithTestCaseCount.UpdateDefectOnlySheet(defectsFromTFS, earliestTime, true);
            updateDefectWithTestCaseCount.UpdateTestCaseWithDefect(defectsFromTFS, allTestCaseInSuite);
            updateDefectWithTestCaseCount.UpdateTfsProposed(defectsFromTFS);
            updateDefectWithTestCaseCount.ExcelCleanup();

            //AddDefectWebApi addDefectWebApi = new AddDefectWebApi();
            //List<Defect> insertedDefects = addDefectWebApi.UpdateListDefects(res).Result;

            //Console.WriteLine(res.Count);
        }
        public void UpdateBothSheets()
        {
            string[] testCaseStatusesFilterBlockedFailed = new string[] { "Blocked", "Failed" };
            string[] testCaseStatusesFilterFailed        = new string[] { "Failed" };

            string[]        critHighSeverity = new string[] { "1 - Critical", "2 - High" };
            List <TestCase> critHighTestCasesReadyForTest = GetTestCasesWebApi.GetTestCasesReadyForTest(critHighSeverity, testCaseStatusesFilterBlockedFailed).Result;

            _critHighDefects = UpdateSingleSheet(_critHighDefects, critHighTestCasesReadyForTest);

            string[]        medLowSeverity = new string[] { "3 - Medium", "4 - Low" };
            List <TestCase> medLowTestCasesReadyForTest = GetTestCasesWebApi.GetTestCasesReadyForTest(medLowSeverity, testCaseStatusesFilterBlockedFailed).Result;

            _mediumLowDefects = UpdateSingleSheet(_mediumLowDefects, medLowTestCasesReadyForTest);
        }
Exemplo n.º 7
0
        public void UpdateExcelExecutionInputData()
        {
            List <TestCase> allTestCaseInSuite;

            if (_props.UseWebApi == 1)
            {
                allTestCaseInSuite = GetTestCasesWebApi.GetAllTestCases().Result;
            }
            else
            {
                GetTestCasesInSuite getTestCasesInSuite = new GetTestCasesInSuite(_props);
                allTestCaseInSuite = getTestCasesInSuite.GatherTestCases();
            }

            UpdateExecutionInputData updateInputData = new UpdateExecutionInputData(_props);

            updateInputData.UpdateExcelExecutionInputData(allTestCaseInSuite);

            updateInputData.ExcelCleanup();
        }
Exemplo n.º 8
0
        public void UpdateTestCaseWithDefect(List <Defect> defects, List <TestCase> testCases = null)
        {
            //_testCaseWithDefect = ClearExcelSheetExceptHeader(_testCaseWithDefect, "A", "I");
            TFSCommon.ExcelTools.ExcelTools.ClearExcelSheetExceptHeader(_testCaseWithDefect, "A", "I");

            int rowCount = 2;

            List <String> filterOutArray = new List <String> {
            };

            //Console.WriteLine(defects.Count);

            var filteredDefects = defects.Where(o => !filterOutArray.Contains(o.Status)).ToList <Defect>();

            //Console.WriteLine(filteredDefects.Count);

            Dictionary <int, TestCase> testCaseCollection = new Dictionary <int, TestCase>();

            Dictionary <int, TestCase> testCaseMap = null;

            if (testCases != null)
            {
                testCaseMap = new Dictionary <int, TestCase>();
                foreach (TestCase curr in testCases)
                {
                    testCaseMap[curr.TestCaseId] = curr;
                }
            }

            List <int> testCaseIdsWithDefects = new List <int>();

            foreach (Defect currDefect in defects)
            {
                if (!filterOutArray.Contains(currDefect.Status) && currDefect.TestCases != null)
                {
                    foreach (TestCase currTestCase in currDefect.TestCases)
                    {
                        TestCase gatheredTestCase;
                        if (!testCaseCollection.ContainsKey(currTestCase.TestCaseId))
                        {
                            if (testCases != null)
                            {
                                gatheredTestCase = testCaseMap[currTestCase.TestCaseId];
                            }
                            else
                            {
                                gatheredTestCase = GetTestCasesWebApi.GetTestCaseById(currTestCase.TestCaseId).Result;
                                testCaseCollection[currTestCase.TestCaseId] = gatheredTestCase;
                            }
                        }
                        else
                        {
                            gatheredTestCase = testCaseCollection[currTestCase.TestCaseId];
                        }
                        // Inserting Test Case portion
                        _testCaseWithDefect.Cells[rowCount, 1].Value = gatheredTestCase.TestCaseId;
                        _testCaseWithDefect.Cells[rowCount, 2].Value = gatheredTestCase.TestCaseName;
                        if (gatheredTestCase.CurrentTestCaseResult != null)
                        {
                            _testCaseWithDefect.Cells[rowCount, 3].Value = gatheredTestCase.CurrentTestCaseResult.Result;
                        }
                        _testCaseWithDefect.Cells[rowCount, 4].Value = gatheredTestCase.TestCasePath;

                        _testCaseWithDefect.Cells[rowCount, 12].Value = gatheredTestCase.TestCaseId + "" +
                                                                        gatheredTestCase.TestSuiteId +
                                                                        gatheredTestCase.TestCaseName;

                        //Inserting Defect portion
                        _testCaseWithDefect.Cells[rowCount, 5].Value  = currDefect.DefectId;
                        _testCaseWithDefect.Cells[rowCount, 6].Value  = currDefect.Status;
                        _testCaseWithDefect.Cells[rowCount, 7].Value  = currDefect.DefectName;
                        _testCaseWithDefect.Cells[rowCount, 8].Value  = currDefect.DefectSeverity;
                        _testCaseWithDefect.Cells[rowCount, 9].Value  = currDefect.FoundInEnvironment;
                        _testCaseWithDefect.Cells[rowCount, 10].Value = currDefect.DefectCreatedBy;
                        _testCaseWithDefect.Cells[rowCount, 11].Value = currDefect.AssignedTo;

                        rowCount += 1;

                        if (!testCaseIdsWithDefects.Contains(currTestCase.TestCaseId))
                        {
                            testCaseIdsWithDefects.Add(currTestCase.TestCaseId);
                        }
                    }
                }
            }

            List <string> failedFilter = new List <string> {
                "Failed", "Blocked"
            };

            if (testCases != null)
            {
                foreach (TestCase testCase in testCases)
                {
                    //TestCase gatheredTestCase = getTestCasesWebApi.GetTestCaseById(testCase.TestCaseId).Result;
                    if (!testCaseIdsWithDefects.Contains(testCase.TestCaseId) &&
                        testCase.CurrentTestCaseResult != null &&
                        failedFilter.Contains(testCase.CurrentTestCaseResult.Result))
                    {
                        _testCaseWithDefect.Cells[rowCount, 1].Value = testCase.TestCaseId;
                        _testCaseWithDefect.Cells[rowCount, 2].Value = testCase.TestCaseName;
                        if (testCase.CurrentTestCaseResult != null)
                        {
                            _testCaseWithDefect.Cells[rowCount, 3].Value = testCase.CurrentTestCaseResult.Result;
                        }
                        _testCaseWithDefect.Cells[rowCount, 4].Value = testCase.TestCasePath;

                        rowCount += 1;
                    }
                }
            }
        }