예제 #1
0
        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());
        }
예제 #2
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);
        }
예제 #3
0
 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);
         }
     }
 }
        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());
        }
예제 #5
0
        public void Should_serialize_test_run_message()
        {
            var testResults = new TestResult[] { new TestResult(TestRunner.NUnit, TestRunStatus.Passed, "Test name", "message", new IStackLine[] { new StackLineMessage("method name", "file", 13) }, 34) };
            var results     = new TestRunResults("project 1", "assembly", false, TestRunner.NUnit, testResults);

            results.SetTimeSpent(new TimeSpan(12345));
            var message = new TestRunMessage(results);
            var output  = serializeDeserialize <TestRunMessage>(message);

            output.Results.Project.ShouldEqual("project 1");
            output.Results.Assembly.ShouldEqual("assembly");
            output.Results.IsPartialTestRun.ShouldBeFalse();
            output.Results.TimeSpent.ShouldEqual(new TimeSpan(12345));
            output.Results.All.Length.ShouldEqual(1);
            output.Results.All[0].Runner.ShouldEqual(TestRunner.NUnit);
            output.Results.All[0].Status.ShouldEqual(TestRunStatus.Passed);
            output.Results.All[0].Name.ShouldEqual("Test name");
            output.Results.All[0].Message.ShouldEqual("message");
            output.Results.All[0].StackTrace[0].Method.ShouldEqual("method name");
            output.Results.All[0].StackTrace[0].File.ShouldEqual("file");
            output.Results.All[0].StackTrace[0].LineNumber.ShouldEqual(13);
            output.Results.All[0].TimeSpent.TotalMilliseconds.ShouldEqual(34);
        }