Пример #1
0
        private TestResult calculateTestResultByPlans(ITestManagementTeamProject project, ITestPlan testPlan)
        {
            var testResult = new TestResult();
            testResult.Name = string.Format("{0} - {1}", testPlan.Iteration, testPlan.Name);
            var testSuites = new List<ITestSuiteBase>();
            if (testPlan.RootSuite != null) testSuites.AddRange(GetTestSuiteRecursive(testPlan.RootSuite));

            foreach (var testSuite in testSuites)
            {

                string queryForTestPointsForSpecificTestSuite = string.Format(CultureInfo.InvariantCulture, "SELECT * FROM TestPoint WHERE SuiteId = {0}", testSuite.Id);
                var testPoints = testPlan.QueryTestPoints(queryForTestPointsForSpecificTestSuite);

                foreach (var point in testPoints)
                {
                    // only get the last result for the current test point
                    // otherwise we would mix test results with different users
                    var result = project
                        .TestResults
                        .ByTestId(point.TestCaseId)
                        .LastOrDefault(testResultToFind => testResultToFind.TestPointId == point.Id);
                    updateTestResultWithOutcome(testResult, result);
                }
            }
            return testResult;
        }
Пример #2
0
 private void updateTestResultWithOutcome(TestResult resultToUpdate, ITestResult resultToUpdateWith)
 {
     resultToUpdate.TotalTestCount++;
     // for some test points we might have no results yet
     if (resultToUpdateWith == null)
     {
         resultToUpdate.NotRunTestCount++;
         return;
     }
     switch (resultToUpdateWith.Outcome)
     {
         case TestOutcome.Passed:
             resultToUpdate.PassedTestCount++;
             break;
         case TestOutcome.Failed:
             resultToUpdate.FailedTestCount++;
             break;
         default:
             resultToUpdate.NotRunTestCount++;
             break;
     }
 }