public ReportResult GetReport()
        {
            ReportResult result = new ReportResult();

            result.Date = DateTime.Now;

            foreach (TreeTestDomain td in this.list)
            {
                if (td.TestEngine == null)
                {
                    continue;
                }
                if (td.TestEngine.Report == null)
                {
                    continue;
                }
                if (td.TestEngine.Report.Result == null)
                {
                    continue;
                }

                result.Merge(td.TestEngine.Report.Result);
            }

            result.UpdateCounts();
            return(result);
        }
Beispiel #2
0
        private void GenerateReport(MainArguments parsedArgs, ReportResult result)
        {
            result.UpdateCounts();
            if (parsedArgs.ReportTypes != null && parsedArgs.ReportTypes.Length > 0)
            {
                parsedArgs.ReportFolder = ReportBase.GetAppDataPath(parsedArgs.ReportFolder);
                consoleOut.WriteLine("[info] Creating reports in {0}", Path.GetFullPath(parsedArgs.ReportFolder));
                foreach (ReportType rt in parsedArgs.ReportTypes)
                {
                    string outputPath = null;
                    switch (rt)
                    {
                    case ReportType.Xml:
                        outputPath = XmlReport.RenderToXml(result, parsedArgs.ReportFolder, parsedArgs.Transform, parsedArgs.ReportNameFormat);
                        consoleOut.WriteLine("[info] Created xml report {0}", outputPath);
                        break;

                    case ReportType.Html:
                        outputPath = HtmlReport.RenderToHtml(result, parsedArgs.ReportFolder, parsedArgs.Transform, parsedArgs.ReportNameFormat);
                        consoleOut.WriteLine("[info] Created Html report {0}", outputPath);
                        break;

                    case ReportType.Text:
                        outputPath = TextReport.RenderToText(result, parsedArgs.ReportFolder, parsedArgs.Transform, parsedArgs.ReportNameFormat);
                        consoleOut.WriteLine("[info] Created Text report {0}", outputPath);
                        break;

                    case ReportType.Dox:
                        outputPath = DoxReport.RenderToDox(result, parsedArgs.ReportFolder, parsedArgs.ReportNameFormat);
                        consoleOut.WriteLine("[info] Created Dox report {0}", outputPath);
                        break;
                    }
                    if (parsedArgs.ShowReports && File.Exists(outputPath))
                    {
                        System.Diagnostics.Process.Start(outputPath);
                    }
                }
            }
        }
Beispiel #3
0
        public ReportResult RunTests()
        {
            ReportResult result = new ReportResult();

            if (graph.VerticesCount == 0)
            {
                this.OnLog("No assembly to execute");
                result.UpdateCounts();
                return(result);
            }

            this.OnLog("Sorting assemblies by dependencies");
            // create topological sort
            ArrayList sortedVertices      = new ArrayList();
            TopologicalSortAlgorithm topo = new TopologicalSortAlgorithm(graph);

            topo.Compute(sortedVertices);
            if (sortedVertices.Count == 0)
            {
                throw new InvalidOperationException("Cannot be zero");
            }

            // set vertices colors
            this.OnLog("Setting up fixture colors");
            VertexColorDictionary colors = new VertexColorDictionary();

            foreach (TestDomainVertex v in graph.Vertices)
            {
                colors.Add(v, GraphColor.White);
            }

            // execute each domain
            foreach (TestDomainVertex v in sortedVertices)
            {
                // if vertex color is not white, skip it
                GraphColor color = colors[v];
                if (color != GraphColor.White)
                {
                    this.OnLog("Skipping assembly {0} because dependent assembly failed", v.Domain.TestEngine.Explorer.AssemblyName);
                    // mark children
                    foreach (TestDomainVertex child in graph.AdjacentVertices(v))
                    {
                        colors[child] = GraphColor.Black;
                    }
                    continue;
                }

                this.OnLog("Loading {0}", v.Domain.TestEngine.Explorer.AssemblyName);

                ReportCounter counter = v.Domain.TestEngine.GetTestCount();
                this.OnLog("Found  {0} tests", counter.RunCount);
                this.OnLog("Running fixtures.");
                v.Domain.TestEngine.RunPipes();
                counter = v.Domain.TestEngine.GetTestCount();
                this.OnLog("Tests finished: {0} tests, {1} success, {2} failures, {3} ignored"
                           , counter.RunCount
                           , counter.SuccessCount
                           , counter.FailureCount
                           , counter.IgnoreCount
                           );

                result.Merge(v.Domain.TestEngine.Report.Result);

                if (counter.FailureCount != 0)
                {
                    // mark children as failed
                    colors[v] = GraphColor.Black;
                    foreach (TestDomainVertex child in graph.AdjacentVertices(v))
                    {
                        colors[child] = GraphColor.Black;
                    }
                }
                else
                {
                    // mark vertex as succesfull
                    colors[v] = GraphColor.Gray;
                }
            }

            result.UpdateCounts();
            MbUnit.Framework.Assert.IsNotNull(result);
            MbUnit.Framework.Assert.IsNotNull(result.Counter);

            this.OnLog("All Tests finished: {0} tests, {1} success, {2} failures, {3} ignored in {4} seconds"
                       , result.Counter.RunCount
                       , result.Counter.SuccessCount
                       , result.Counter.FailureCount
                       , result.Counter.IgnoreCount
                       , result.Counter.Duration
                       );

            return(result);
        }