public List<TestRunResults> RemoveUnmatchedRunInfoTests(TestRunResults[] results, TestRunInfo[] infos)
        {
            var tests = new List<TestItem>();
            tests.AddRange(_cache.Failed);
            tests.AddRange(_cache.Ignored);

            var removed = new List<TestRunResults>();
            infos
                .Where(i => results.Count(x => i.Assembly.Equals(x.Assembly)) == 0).ToList()
                .ForEach(i =>
                    {
                        tests.Where(x => x.Key.Equals(i.Assembly) &&
                                   (!i.OnlyRunSpcifiedTestsFor(x.Value.Runner) || i.GetTestsFor(x.Value.Runner).Count(t => t.Equals(x.Value.Name)) > 0))
                            .GroupBy(x => x.Value.Runner).ToList()
                            .ForEach(x => 
                                {
                                    removed.Add(new TestRunResults(
                                        i.Project.Key,
                                        i.Assembly,
                                        i.OnlyRunSpcifiedTestsFor(TestRunner.Any),
                                        x.Key,
                                        x.Select(t => new TestResult(
                                            t.Value.Runner,
                                            TestRunStatus.Passed,
                                            t.Value.Name,
                                            t.Value.Message,
                                            t.Value.StackTrace,
                                            t.Value.TimeSpent.TotalMilliseconds).SetDisplayName(t.Value.DisplayName)).ToArray()));
                                });
                    });
            return removed;
        }
        public IEnumerable<TestRunResults> Parse()
        {
            var doc = new XPathDocument(_reportFile);
            var nav = doc.CreateNavigator();

            var assemblies = nav.Select("/MSpec/assembly").OfType<XPathNavigator>();

            return assemblies
                .Select(assembly => new Assembly
                                    {
                                        AssemblyLocation = assembly.GetAttribute("location", ""),
                                        TimeSpent = ReadTimeSpan(assembly),
                                        ContextSpecifications = ContextSpecificationsFor(assembly)
                                    })
                .Select(x =>
                    {
                        x.AssociatedRunInfo = FindRunInfo(_run, x);
                        return x;
                    })
                .Where(x => x.AssociatedRunInfo != null)
                .Select(x =>
                    {
                        var results = new TestRunResults(x.AssociatedRunInfo.Project.Key,
                                                         x.AssociatedRunInfo.Assembly,
                                                         _run.RunInfos.Any(),
                                                         TestRunner.MSpec,
                                                         TestResultsFor(x.ContextSpecifications));
                        results.SetTimeSpent(x.TimeSpent);
                        return results;
                    })
                .ToList();
        }
        public void Should_locate_removed_test_in_partial_test_run()
        {
            int i = 3;
            var results = new TestRunResults("project1", "assembly", false, new TestResult[]
                                                    {
                                                        new TestResult(TestRunner.NUnit, TestRunStatus.Failed, "Test1"),
                                                        new TestResult(TestRunner.NUnit, TestRunStatus.Ignored, "Test2"),
                                                        new TestResult(TestRunner.NUnit, TestRunStatus.Failed, "Test3"),
                                                        new TestResult(TestRunner.NUnit, TestRunStatus.Failed, "Test4")
                                                    });
            var cache = new RunResultCache();
            cache.Merge(results);

            var infos = new TestRunInfo[] { new TestRunInfo(new Project("project", new ProjectDocument(ProjectType.CSharp)), "assembly") };
            infos[0].AddTestsToRun(new TestToRun[] { new TestToRun(TestRunner.NUnit, "Test1"), new TestToRun(TestRunner.NUnit, "Test2"), new TestToRun(TestRunner.NUnit, "Test3") });
            results = new TestRunResults("project1", "assembly", true, new TestResult[]
                                                    {
                                                        new TestResult(TestRunner.NUnit, TestRunStatus.Ignored, "Test1")
                                                    });

            var locator = new RemovedTestsLocator(cache);
            results = locator.SetRemovedTestsAsPassed(results, infos);

            results.Passed.Length.ShouldEqual(2);
            results.Passed[0].Name.ShouldEqual("Test3");
            results.Passed[1].Name.ShouldEqual("Test2");
        }
        public void Should_not_remove_tests_from_different_runners()
        {
            var cache = new RunResultCache();
            cache.EnabledDeltas();
            var results = new TestRunResults("project", "assembly", false, TestRunner.NUnit, new TestResult[]
                                                    {
                                                        new TestResult(TestRunner.NUnit, TestRunStatus.Failed, "Test1"),
                                                    });
            cache.Merge(results);
            var mah = cache.PopDeltas();
            mah.AddedTests.Length.ShouldEqual(1);

            var infos = new TestRunInfo[] { new TestRunInfo(new Project("project", new ProjectDocument(ProjectType.CSharp)), "assembly") };
            results = new TestRunResults("project", "assembly", false, TestRunner.XUnit, new TestResult[]
                                                    {
                                                        new TestResult(TestRunner.XUnit, TestRunStatus.Failed, "Test1"),
                                                    });

            var locator = new RemovedTestsLocator(cache);
            results = locator.SetRemovedTestsAsPassed(results, infos);
            cache.Merge(results);

            results.Passed.Length.ShouldEqual(0);

            var meh = cache.PopDeltas();
            meh.RemovedTests.Length.ShouldEqual(0);
        }
 public TestRunResults SetRemovedTestsAsPassed(TestRunResults results, TestRunInfo[] infos)
 {
     _results = results;
     _infos = infos;
     var tests = new List<TestResult>();
     tests.AddRange(results.All);
     tests.AddRange(getTests(_cache.Failed));
     tests.AddRange(getTests(_cache.Ignored));
     var modified = new TestRunResults(_results.Project, _results.Assembly, _results.IsPartialTestRun, _results.Runner, tests.ToArray());
     modified.SetTimeSpent(_results.TimeSpent);
     return modified;
 }
 private static void handleSuite(XmlNodeList suites, List<TestRunResults> results, string testLocation) {
     foreach (XmlNode suite in suites) {
         handleSuite(suite.SelectNodes("testsuite"), results, testLocation);
         var tests = getTests(suite);
         if (tests.Count() > 0) {
             var result 
                 = new TestRunResults(
                     suite.Attributes["name"].Value,
                     testLocation,
                     false,
                     TestRunner.PhpUnit, tests.ToArray());
             result.SetTimeSpent(TimeSpan.FromMilliseconds(1000*double.Parse(suite.Attributes["time"].Value)));
             results.Add(result);
         }
     }
 }
        public void Should_locate_removed_test_in_full_test_run()
        {
            var results = new TestRunResults("project1", "assembly", false, new TestResult[]
                                                    {
                                                        new TestResult(TestRunner.NUnit, TestRunStatus.Failed, "Test1"),
                                                        new TestResult(TestRunner.NUnit, TestRunStatus.Ignored, "Test2"),
                                                        new TestResult(TestRunner.NUnit, TestRunStatus.Failed, "Test3")
                                                    });
            var cache = new RunResultCache();
            cache.Merge(results);
            
            results = new TestRunResults("project1", "assembly", false, new TestResult[]
                                                    {
                                                        new TestResult(TestRunner.NUnit, TestRunStatus.Ignored, "Test1")
                                                    });

            var locator = new RemovedTestsLocator(cache);
            results =  locator.SetRemovedTestsAsPassed(results, null);
            
            results.Passed.Length.ShouldEqual(2);
            results.Passed[0].Name.ShouldEqual("Test3");
            results.Passed[1].Name.ShouldEqual("Test2");
        }
		public void SetDataFrom(BinaryReader reader)
		{
			_results = new TestRunResults("", "", new TestResult[] {});
			_results.SetDataFrom(reader);
		}
 public TestRunMessage(TestRunResults results)
 {
     _results = results;
 }
Exemple #10
0
 public void SetDataFrom(BinaryReader reader)
 {
     _results = new TestRunResults("", "", false, TestRunner.Any, new TestResult[] {});
     _results.SetDataFrom(reader);
 }
Exemple #11
0
 public TestRunMessage(TestRunResults results)
 {
     _results = results;
 }
 private TestRunResults[] getResults(IEnumerable<AutoTest.TestRunners.Shared.Results.TestResult> tests, TestRunInfo[] runInfos)
 {
     var results = new List<TestRunResults>();
     foreach (var byRunner in tests.GroupBy(x => x.Runner))
     {
         var runner = TestRunnerConverter.FromString(byRunner.Key);
         foreach (var byAssembly in byRunner.GroupBy(x => x.Assembly))
         {
             var info = runInfos.Where(x => x.Assembly.Equals(byAssembly.Key)).FirstOrDefault();
             var project = "";
             var partial = false;
             if (info != null)
             {
                 if (info.Project != null)
                     project = info.Project.Key;
                 partial = info.OnlyRunSpcifiedTestsFor(runner) ||
                           info.GetTestsFor(runner).Count() > 0 ||
                           info.GetMembersFor(runner).Count() > 0 ||
                           info.GetNamespacesFor(runner).Count() > 0;
             }
             DebugLog.Debug.WriteDetail(string.Format("Partial run is {0} for runner {1}", partial, runner));
             
             var result = new TestRunResults(
                                 project,
                                 byAssembly.Key,
                                 partial,
                                 runner,
                                 byAssembly.Select(x => ConvertResult(x)).ToArray());
             result.SetTimeSpent(TimeSpan.FromMilliseconds(byAssembly.Sum(x => x.DurationInMilliseconds)));
             results.Add(result);
         }
     }
     return results.ToArray();
 }
        public void Should_remove_tests_for_run_infos_having_run_all_tests()
        {
            var results = new TestRunResults("project1", "assembly", false, TestRunner.NUnit, new TestResult[]
                                                    {
                                                        new TestResult(TestRunner.NUnit, TestRunStatus.Failed, "Test1")
                                                    });
            var cache = new RunResultCache();
            cache.Merge(results);

            var runInfo = new TestRunInfo(new Project("project1", new ProjectDocument(ProjectType.CSharp)), "assembly");
            
            var locator = new RemovedTestsLocator(cache);
            var output = locator.RemoveUnmatchedRunInfoTests(new TestRunResults[] {}, new TestRunInfo[] { runInfo });

            output.Count.ShouldEqual(1);
            output[0].Passed.Length.ShouldEqual(1);
            output[0].Passed[0].Name.ShouldEqual("Test1");
        }