Description of TestStatistics.
        protected override void BeginProcessing()
        {
//            var stat = new TestStat();
//            
//            if (null != TestData.TestSuites && 0 < TestData.TestSuites.Count) {
//                
//                // 20141107
//                var testStatistics = new TestStatistics();
//                
//                foreach (var testSuite in TestData.TestSuites) {
//                    
//                    // 20141107
//                    // TestData.RefreshSuiteStatistics(testSuite, false);
//                    testStatistics.RefreshSuiteStatistics(testSuite, false);
//                    stat.Passed += testSuite.Statistics.Passed;
//                    stat.Failed += testSuite.Statistics.Failed;
//                    stat.PassedButWithBadSmell += testSuite.Statistics.PassedButWithBadSmell;
//                    stat.NotTested += testSuite.Statistics.NotTested;
//                    stat.All += testSuite.Statistics.All;
//                }
//                
//            }
            var testStatistics = new TestStatistics();
            var stat = testStatistics.RefreshAllStatistics(TestData.TestSuites, false);
            WriteObject(this, stat);
        }
Ejemplo n.º 2
0
 public void MergeTestSuites(List<ITestSuite> sourceTestSuites, List<ITestSuite> testSuitesToAdd)
 {
     var testStatistics = new TestStatistics();
     
     foreach (var testSuite in testSuitesToAdd) {
         if (sourceTestSuites.All(ts => ts.UniqueId != testSuite.UniqueId)) {
             // 20150219
             // TODO: move it to another place
             testStatistics.RefreshSuiteStatistics(testSuite, false);
             sourceTestSuites.Add(testSuite);
             continue;
         }
         var existingTestSuite = sourceTestSuites.First(ts => ts.UniqueId == testSuite.UniqueId);
         MergeTestScenarios(existingTestSuite.TestScenarios, testSuite.TestScenarios);
         testStatistics.RefreshSuiteStatistics(existingTestSuite, false);
     }
 }
Ejemplo n.º 3
0
 void MergeTestScenarios(List<ITestScenario> sourceTestScenarios, List<ITestScenario> testScenariosToAdd)
 {
     var testStatistics = new TestStatistics();
     
     foreach (var testScenario in testScenariosToAdd) {
         if (sourceTestScenarios.All(tsc => tsc.UniqueId != testScenario.UniqueId)) {
             // 20150219
             // TODO: move it to another place
             testStatistics.RefreshScenarioStatistics(testScenario, false);
             sourceTestScenarios.Add(testScenario);
             continue;
         }
         var existingTestScenario = sourceTestScenarios.First(tsc => tsc.UniqueId == testScenario.UniqueId);
         MergeTestResults(existingTestScenario.TestResults, testScenario.TestResults);
         testStatistics.RefreshScenarioStatistics(existingTestScenario, false);
     }
 }
 protected override void BeginProcessing()
 {
     
     if (null != TestData.TestSuites && 0 < TestData.TestSuites.Count) {
         
         // 20141107
         var testStatistics = new TestStatistics();
         
         foreach (var testSuite in TestData.TestSuites) {
             
             // 20141107
             // TestData.RefreshSuiteStatistics(testSuite, false);
             testStatistics.RefreshSuiteStatistics(testSuite, false);
         }
         
     }
     
 }
Ejemplo n.º 5
0
 internal static void SetSuiteStatus(bool skipAutomatic)
 {
     if (null == TestData.CurrentTestSuite)
         TestData.InitCurrentTestScenario();
     
     TestData.SetScenarioStatus(skipAutomatic);
     
     int counterPassedResults = 0;
     int counterKnownIssueResults = 0;
     
     if (TestData.CurrentTestSuite != null && 
         0 < TestData.CurrentTestSuite.TestScenarios.Count) {
         
         foreach (var scenario in TestData.CurrentTestSuite.TestScenarios) {
             
             switch (scenario.enStatus) {
                 case TestScenarioStatuses.Passed:
                     counterPassedResults++;
                     if (TestSuiteStatuses.Failed != TestData.CurrentTestSuite.enStatus)
                         TestData.CurrentTestSuite.enStatus = TestSuiteStatuses.Passed;
                     break;
                 case TestScenarioStatuses.Failed:
                     TestData.CurrentTestSuite.enStatus = TestSuiteStatuses.Failed;
                     return;
                 case TestScenarioStatuses.NotTested:
                     break;
                 case TestScenarioStatuses.KnownIssue:
                     counterKnownIssueResults++;
                     if (TestSuiteStatuses.Failed != TestData.CurrentTestSuite.enStatus)
                         TestData.CurrentTestSuite.enStatus = TestSuiteStatuses.Passed;
                     break;
                 default:
                     // 20130428
                     //throw new Exception("Invalid value for TestScenarioStatuses");
                     // as Not Tested
                     break;
             }
         }
         
         if (0 == counterPassedResults && 0 < counterKnownIssueResults)
             TestData.CurrentTestSuite.enStatus = TestSuiteStatuses.KnownIssue;
         
         // set statistics
         var testStatistics = new TestStatistics();
         testStatistics.RefreshSuiteStatistics(TestData.CurrentTestSuite, skipAutomatic);
     }
 }
Ejemplo n.º 6
0
 internal static void SetScenarioStatus(bool skipAutomatic)
 {
     if (null == TestData.CurrentTestScenario) {
         TestData.InitCurrentTestScenario();
     }
     
     int counterPassedResults = 0;
     int counterKnownIssueResults = 0;
     
     if (null != TestData.CurrentTestScenario &&
         null != TestData.CurrentTestScenario.TestResults &&
         0 < TestData.CurrentTestScenario.TestResults.Count) {
         foreach (var testResult in TestData.CurrentTestScenario.TestResults)
             switch (testResult.enStatus) {
                 case TestResultStatuses.Passed:
                     counterPassedResults++;
                     // 20131001
                     //TestData.CurrentTestScenario.enStatus = TestScenarioStatuses.Passed;
                     if (TestScenarioStatuses.Failed != TestData.CurrentTestScenario.enStatus)
                         TestData.CurrentTestScenario.enStatus = TestScenarioStatuses.Passed;
                     break;
                 case TestResultStatuses.Failed:
                     TestData.CurrentTestScenario.enStatus = TestScenarioStatuses.Failed;
                     return;
             //break;
                 case TestResultStatuses.NotTested:
                     
                     break;
                 case TestResultStatuses.KnownIssue:
                     counterKnownIssueResults++;
                     // 20131001
                     //TestData.CurrentTestScenario.enStatus = TestScenarioStatuses.Passed;
                     if (TestScenarioStatuses.Failed != TestData.CurrentTestScenario.enStatus)
                         TestData.CurrentTestScenario.enStatus = TestScenarioStatuses.Passed;
                     break;
                 default:
                     throw new Exception("Invalid value for TestResultStatuses");
             }
         if (0 == counterPassedResults && 0 < counterKnownIssueResults)
             TestData.CurrentTestScenario.enStatus = TestScenarioStatuses.KnownIssue;
     
         // set statistics
         var testStatistics = new TestStatistics();
         testStatistics.RefreshScenarioStatistics(TestData.CurrentTestScenario, skipAutomatic);
     }
 }
Ejemplo n.º 7
0
        /// <summary>
        /// Performs parametrized search for Test Suites.
        /// </summary>
        /// <param name="cmdlet"></param>
        /// <returns></returns>
        public IOrderedEnumerable<ITestSuite> SearchForSuites(ISearchCmdletBaseDataObject cmdlet, List<ITestSuite> suitesForSearch)
        {
            IOrderedEnumerable<ITestSuite> suitesFound = null;
            // 20141107
            var testStatistics = new TestStatistics();
            
            // Filtering results
            
            // default result
            Func<ITestSuite, bool> query = suite => true;
            
            if (!string.IsNullOrEmpty(cmdlet.FilterNameContains)) {
                query = suite => suite.Name.Contains(cmdlet.FilterNameContains);
                cmdlet.FilterAll = false;
            } else if (!string.IsNullOrEmpty(cmdlet.FilterIdContains)) {
                query = suite => suite.Id.Contains(cmdlet.FilterIdContains);
                cmdlet.FilterAll = false;
            } else if (!string.IsNullOrEmpty(cmdlet.FilterDescriptionContains)) {
                query = suite => suite.Description != null && suite.Description.Contains(cmdlet.FilterDescriptionContains);
                cmdlet.FilterAll = false;
            } else if (cmdlet.FilterPassed) {
                query = suite => suite.enStatus == TestSuiteStatuses.Passed;
                cmdlet.FilterAll = false;
            } else if (cmdlet.FilterFailed) {
                query = suite => suite.enStatus == TestSuiteStatuses.Failed;
                cmdlet.FilterAll = false;
            } else if (cmdlet.FilterNotTested) {
                query = suite => suite.enStatus == TestSuiteStatuses.NotTested;
                cmdlet.FilterAll = false;
            } else if (cmdlet.FilterPassedWithBadSmell) {
                query = suite => suite.enStatus == TestSuiteStatuses.KnownIssue;
                cmdlet.FilterAll = false;
            }
            if (cmdlet.FilterAll) {
                query = suite => true;
            }
            if (cmdlet.FilterNone) {
                query = suite => false;
            }
            
            // Ordering results
            
            // default result
            Func<ITestSuite, object> ordering = suite => suite.Id;
            
            if (cmdlet.OrderByTimeSpent) {
                ordering += suite => suite.Statistics.TimeSpent;
            } 
            if (cmdlet.OrderByName) {
                ordering += suite => suite.Name;
            } 
            if (cmdlet.OrderById) {
                ordering += suite => suite.Id;
            } 
            if (cmdlet.OrderByPassRate) {
                ordering += suite => {
                    testStatistics.RefreshSuiteStatistics(suite, cmdlet.FilterOutAutomaticResults);
                    return (suite.Statistics.Passed / suite.Statistics.All);
                };
            } 
            if (cmdlet.OrderByFailRate) {
                ordering += suite => {
                    testStatistics.RefreshSuiteStatistics(suite, cmdlet.FilterOutAutomaticResults);
                    return (suite.Statistics.Failed / suite.Statistics.All);
                };
            } 
            
            suitesFound = SearchTestSuite(
                suitesForSearch,
                query,
                    //Combine<TestSuite, bool>((x, y) => x && y, queriesList.ToArray()),
                ordering,
                cmdlet.Descending);

            return suitesFound;
        }
Ejemplo n.º 8
0
 // 20140720
 // string getStatisticsStringSuite(TestSuite suite, bool skipAutomatic)
 string getStatisticsStringSuite(ITestSuite suite, bool skipAutomatic)
 {
     string result = string.Empty;
     // 20141107
     // TestData.RefreshSuiteStatistics(suite, skipAutomatic);
     var testStatistics = new TestStatistics();
     testStatistics.RefreshSuiteStatistics(suite, skipAutomatic);
     result += @"<div id=""suitestat"">";
     
     int scPassed = 0;
     int scFailed = 0;
     int scNotTested = 0;
     foreach (var tsc in suite.TestScenarios) {
         switch (tsc.enStatus) {
             case TestScenarioStatuses.Passed:
                 scPassed++;
                 break;
             case TestScenarioStatuses.Failed:
                 scFailed++;
                 break;
             case TestScenarioStatuses.NotTested:
                 scNotTested++;
                 break;
             default:
                 // 20130428
                 //throw new Exception("Invalid value for TestScenarioStatuses");
                 scNotTested++;
                 break;
         }
     }
     
     // scenarios
     result += @"Scenarios:";
     result += suite.TestScenarios.Count.ToString();
     result += "  Passed:";
     result += scPassed.ToString();
     result += "  Failed:";
     result += scFailed.ToString();
     result += "  Not tested:";
     result += scNotTested.ToString();
     result += newLineHTML;
     
     // test results
     result += @"Test cases:";
     result += suite.Statistics.All.ToString();
     result += "  Passed:";
     result += suite.Statistics.Passed.ToString();
     result += "  Failed:";
     result += suite.Statistics.Failed.ToString();
     result += "  Not tested:";
     result += suite.Statistics.NotTested.ToString();
     result += "  Time spent:";
     result += Convert.ToInt32(suite.Statistics.TimeSpent).ToString();
     result += @" seconds</div>";
     return result;
 }
Ejemplo n.º 9
0
 // 20140720
 // string getStatisticsStringScenario(TestScenario scenario, bool skipAutomatic)
 string getStatisticsStringScenario(ITestScenario scenario, bool skipAutomatic)
 {
     string result = string.Empty;
     // 20130322
     //TestData.RefreshScenarioStatistics(scenario);
     // 20141107
     // TestData.RefreshScenarioStatistics(scenario, skipAutomatic);
     var testStatistics = new TestStatistics();
     testStatistics.RefreshScenarioStatistics(scenario, skipAutomatic);
     result += @"<div id=""scenariostat"">";
     
     // test results
     result += @"Test cases:";
     result += scenario.Statistics.All.ToString();
     result += "  Passed:";
     result += scenario.Statistics.Passed.ToString();
     result += "  Failed:";
     result += scenario.Statistics.Failed.ToString();
     result += "  Not tested:";
     result += scenario.Statistics.NotTested.ToString();
     result += "  Time spent:";
     result += Convert.ToInt32(scenario.Statistics.TimeSpent).ToString();
     result += @" seconds</div>";
     return result;
 }
Ejemplo n.º 10
0
        internal void setScenarioStatus(ITestScenario testScenario, bool skipAutomatic)
        {
            int counterPassedResults = 0;
            int counterKnownIssueResults = 0;
            
            if (null != testScenario.TestResults && 0 < testScenario.TestResults.Count) {
                foreach (var testResult in testScenario.TestResults) {

                    switch (testResult.enStatus) {
                        case TestResultStatuses.Passed:
                            counterPassedResults++;
                            if (TestScenarioStatuses.Failed != testScenario.enStatus)
                                testScenario.enStatus = TestScenarioStatuses.Passed;
                            break;
                        case TestResultStatuses.Failed:
                            testScenario.enStatus = TestScenarioStatuses.Failed;
                            return;
                        case TestResultStatuses.NotTested:
                            
                            break;
                        case TestResultStatuses.KnownIssue:
                            counterKnownIssueResults++;
                            if (TestScenarioStatuses.Failed != testScenario.enStatus)
                                testScenario.enStatus = TestScenarioStatuses.Passed;
                            break;
                        default:
                            throw new Exception("Invalid value for TestResultStatuses");
                    }
                }
                if (0 == counterPassedResults && 0 < counterKnownIssueResults)
                    testScenario.enStatus = TestScenarioStatuses.KnownIssue;
                
                var testStatistics = new TestStatistics();
                testStatistics.RefreshScenarioStatistics(testScenario, skipAutomatic);
            }
        }
Ejemplo n.º 11
0
 public List<ITestSuite> ImportTestSuites(IEnumerable<XElement> suiteElements)
 {
     var importedTestSuites = new List<ITestSuite>();
     // TODO: DI
     var testStatistics = new TestStatistics();
     
     foreach (var suiteElement in suiteElements) {
         string suiteDescription = string.Empty;
         suiteDescription = getStringAttribute(suiteElement, "description");
         
         bool addTestSuite = false;
         var testSuite = importedTestSuites.FirstOrDefault(ts => ts.Id == getStringAttribute(suiteElement, "id") &&
                                                  ts.Name == getStringAttribute(suiteElement, "name") &&
                                                  ts.PlatformUniqueId == getGuidAttribute(suiteElement, "platformUniqueId"));
         
         if (null == testSuite) {
             testSuite = new TestSuite {
                 UniqueId = getGuidAttribute(suiteElement, "uniqueId"),
                 Id = getStringAttribute(suiteElement, "id"),
                 Name = getStringAttribute(suiteElement, "name"),
                 PlatformId = getStringAttribute(suiteElement, "platformId"),
                 PlatformUniqueId = getGuidAttribute(suiteElement, "platformUniqueId"),
                 Description = suiteDescription,
                 TimeSpent = getDoubleAttribute(suiteElement, "timeSpent")
             };
             addTestSuite = true;
         }
         
         var scenarioElements = from scenarioElement in suiteElement.Descendants("scenario")
                                     where getStringAttribute(scenarioElement, "name") != TestData.Autogenerated
                                     && testSuite.PlatformUniqueId == getGuidAttribute(scenarioElement, "platformUniqueId")
                                     select scenarioElement;
         testSuite.TestScenarios.AddRange(importTestScenarios(scenarioElements, testSuite.Id, testSuite.UniqueId));
         testStatistics.RefreshSuiteStatistics(testSuite, true);
         setSuiteStatus(testSuite, true);
         if (addTestSuite)
            importedTestSuites.Add(testSuite);
     }
     return importedTestSuites;
 }
Ejemplo n.º 12
0
 public static string GetTestScenarioStatus(IOpenScenarioCmdletBaseDataObject dataObject, bool skipAutomatic)
 {
     TmxHelper.OpenTestScenario(dataObject);
     if (null == TestData.CurrentTestScenario) return string.Empty;
     var testStatistics = new TestStatistics();
     testStatistics.RefreshScenarioStatistics(TestData.CurrentTestScenario, skipAutomatic);
     return TestData.CurrentTestScenario.Status;
 }
Ejemplo n.º 13
0
 public static string GetTestSuiteStatusById(string id, Guid testPlatformId, bool skipAutomatic)
 {
     TmxHelper.OpenTestSuite(
         string.Empty,
         id,
         testPlatformId);
     if (null == TestData.CurrentTestSuite) return string.Empty;
     var testStatistics = new TestStatistics();
     testStatistics.RefreshSuiteStatistics(TestData.CurrentTestSuite, skipAutomatic);
     return TestData.CurrentTestSuite.Status;
 }
Ejemplo n.º 14
0
 public static string GetCurrentTestSuiteStatus(IOpenSuiteCmdletBaseDataObject cmdlet, bool skipAutomatic)
 {
     if (null == TestData.CurrentTestSuite) return string.Empty;
     var testStatistics = new TestStatistics();
     testStatistics.RefreshSuiteStatistics(TestData.CurrentTestSuite, skipAutomatic);
     return TestData.CurrentTestSuite.Status;
 }
Ejemplo n.º 15
0
//        public static bool ImportTestStructure(string path)
//        {
//            bool result = false;
//            
//            
//            return result;
//        }
        
//        public static bool ExportTestStructure(string path)
//        {
//            bool result = false;
//            
//            
//            return result;
//        }
        #endregion Import/export test structure
        
        #region Search
        /// <summary>
        /// Performs parametrized search for Test Suites.
        /// </summary>
        /// <param name="cmdlet"></param>
        /// <returns></returns>
        public static IOrderedEnumerable<ITestSuite> SearchForSuites(ISearchCmdletBaseDataObject cmdlet)
        {
            IOrderedEnumerable<ITestSuite> suites = null;
            // 20141107
            var testStatistics = new TestStatistics();
            
            // Filtering results
            
            // default result
            Func<ITestSuite, bool> query = suite => true;
            
//            System.Collections.Generic.List<Func<TestSuite, bool>> queriesList =
//                new List<Func<TestSuite, bool>>();
//            queriesList.Add(query);
            
            if (!string.IsNullOrEmpty(cmdlet.FilterNameContains)) {
            // if (cmdlet.FilterNameContains != null && cmdlet.FilterNameContains.Length > 0) {
                query = suite => suite.Name.Contains(cmdlet.FilterNameContains);
                //queriesList.Add((suite => suite.Name.Contains(cmdlet.FilterNameContains)));
                cmdlet.FilterAll = false;
            } else if (!string.IsNullOrEmpty(cmdlet.FilterIdContains)) {
            // } else if (cmdlet.FilterIdContains != null && cmdlet.FilterIdContains.Length > 0) {
                query = suite => suite.Id.Contains(cmdlet.FilterIdContains);
                //queriesList.Add((suite => suite.Id.Contains(cmdlet.FilterIdContains)));
                cmdlet.FilterAll = false;
            } else if (!string.IsNullOrEmpty(cmdlet.FilterDescriptionContains)) {
            // } else if (cmdlet.FilterDescriptionContains != null && cmdlet.FilterDescriptionContains.Length > 0) {
                query = suite => suite.Description != null && suite.Description.Contains(cmdlet.FilterDescriptionContains);

                //query = suite =>
                //{
                //    return suite.Description != null && suite.Description.Contains(cmdlet.FilterDescriptionContains);

                //    /*
                //        if (suite.Description != null) {
                //            return suite.Description.Contains(cmdlet.FilterDescriptionContains);
                //        }
                //        return false;
                //        */
                //};

//                queriesList.Add((suite =>
//                    {
//                        if (suite.Description != null) {
//                            return suite.Description.Contains(cmdlet.FilterDescriptionContains);
//                        }
//                        return false;
//                    }));
                cmdlet.FilterAll = false;
            } else if (cmdlet.FilterPassed) {
                query = suite => suite.enStatus == TestSuiteStatuses.Passed;
                //queriesList.Add((suite => suite.enStatus == TestSuiteStatuses.Passed));
                cmdlet.FilterAll = false;
            } else if (cmdlet.FilterFailed) {
                query = suite => suite.enStatus == TestSuiteStatuses.Failed;
                //queriesList.Add((suite => suite.enStatus == TestSuiteStatuses.Failed));
                cmdlet.FilterAll = false;
            } else if (cmdlet.FilterNotTested) {
                query = suite => suite.enStatus == TestSuiteStatuses.NotTested;
                //queriesList.Add((suite => suite.enStatus == TestSuiteStatuses.NotTested));
                cmdlet.FilterAll = false;
            } else if (cmdlet.FilterPassedWithBadSmell) {
                query = suite => suite.enStatus == TestSuiteStatuses.KnownIssue;
                //queriesList.Add((suite => suite.enStatus == TestSuiteStatuses.KnownIssue));
                cmdlet.FilterAll = false;
            }
            if (cmdlet.FilterAll) {
                query = suite => true;
            }
            if (cmdlet.FilterNone) {
                query = suite => false;
                //queriesList.Clear();
                //queriesList.Add(query);
            }
            
            // Ordering results
            
            // default result
            // 20140720
            // Func<TestSuite, object> ordering = suite => suite.Id;
            Func<ITestSuite, object> ordering = suite => suite.Id;
            
            if (cmdlet.OrderByTimeSpent) {
                ordering += suite => suite.Statistics.TimeSpent;
            } 
            if (cmdlet.OrderByName) {
                ordering += suite => suite.Name;
            } 
            if (cmdlet.OrderById) {
                ordering += suite => suite.Id;
            } 
            if (cmdlet.OrderByPassRate) {
                ordering += suite => {
                    //TestData.RefreshSuiteStatistics(suite);
                    // 20141107
                    // TestData.RefreshSuiteStatistics(suite, cmdlet.FilterOutAutomaticResults);
                    testStatistics.RefreshSuiteStatistics(suite, cmdlet.FilterOutAutomaticResults);
                    return (suite.Statistics.Passed / suite.Statistics.All);
                };
            } 
            if (cmdlet.OrderByFailRate) {
                ordering += suite => {
                    //TestData.RefreshSuiteStatistics(suite);
                    // 20141107
                    // TestData.RefreshSuiteStatistics(suite, cmdlet.FilterOutAutomaticResults);
                    testStatistics.RefreshSuiteStatistics(suite, cmdlet.FilterOutAutomaticResults);
                    return (suite.Statistics.Failed / suite.Statistics.All);
                };
            } 

//            cmdlet.WriteVerbose(cmdlet, "query = " + query);
//            cmdlet.WriteVerbose(cmdlet, "ordering = " + ordering);
            
            suites = 
                TestData.SearchTestSuite(
                    query,
                    //Combine<TestSuite, bool>((x, y) => x && y, queriesList.ToArray()),
                    ordering,
                    cmdlet.Descending);

            return suites;
        }