Exemplo n.º 1
0
 public virtual void VisitResult(ReportResult result)
 {
     foreach (ReportAssembly assembly in result.Assemblies)
     {
         VisitAssembly(assembly);
     }
 }
Exemplo n.º 2
0
 public ReportResultExplorer(ReportResult result)
 {
     if (result == null)
         throw new ArgumentNullException("result");
     this.result = result;
     this.BuildDictionaries();
 }
        public override void Render(ReportResult result, TextWriter writer)
        {
            if (this.transform==null) throw new ApplicationException("Transform property cannot be null");
            // create xml report and render
            using (StringWriter xmlWriter = new StringWriter())
            {
                XmlReport report = new XmlReport();
                report.Render(result, xmlWriter);

                // load xslt
                XmlDocument doc = new XmlDocument();
                XsltArgumentList args = new XsltArgumentList();

                XmlTextWriter owriter = new XmlTextWriter(writer);
                owriter.Formatting = Formatting.Indented;

                    doc.LoadXml(xmlWriter.ToString());
                    this.transform.Transform(
                        doc,
                        args,
                        owriter
                        );
                    owriter.Flush();
                    owriter.Close();
            }
        }
Exemplo n.º 4
0
		public static string RenderToDox(ReportResult result, string outputPath, string nameFormat)
		{
            if (result == null)
				throw new ArgumentNullException("result");
            DoxReport textReport = new DoxReport();
            return textReport.Render(result, outputPath, nameFormat);
        }
Exemplo n.º 5
0
        public static string RenderToHtml(ReportResult result)
        {
            if (result == null)
                throw new ArgumentNullException("result");

            HtmlReport htmlReport = new HtmlReport();
            ResourceHelper.CreateImages(GetAppDataPath(""));
            return htmlReport.Render(result);
        }
Exemplo n.º 6
0
		public void Merge(ReportResult result, bool updateCounts)
		{
			foreach(ReportAssembly assembly in result.Assemblies)
			{
				this.Assemblies.AddReportAssembly(assembly);
			}
			if (updateCounts)
				this.UpdateCounts();
		}
Exemplo n.º 7
0
 public ReportResultExplorer(ReportResult result)
 {
     if (result == null)
     {
         throw new ArgumentNullException("result");
     }
     this.result = result;
     this.BuildDictionaries();
 }
        public static void RenderReport(ReportResult result, Task task)
        {
            Ensure.ArgumentIsNotNull(result, "result");
            Ensure.ArgumentIsNotNull(task, "task");

            ITeamCityMessageProvider messageProvider = IoC.Resolve<ITeamCityMessageProvider>(new { taskToUseForLogging = task });

            TeamCityReportGenerator report = new TeamCityReportGenerator();
            report.Render(result, messageProvider);
        }
Exemplo n.º 9
0
		public void StartTests()
		{
			this.result = new ReportResult();
			this.result.Date = DateTime.Now;
			this.result.Counter = new ReportCounter();

			this.assemblies.Clear();
			this.namespaces.Clear();
			this.fixtures.Clear();
		}
Exemplo n.º 10
0
        public void StartTests()
        {
            this.result         = new ReportResult();
            this.result.Date    = DateTime.Now;
            this.result.Counter = new ReportCounter();

            this.assemblies.Clear();
            this.namespaces.Clear();
            this.fixtures.Clear();
        }
Exemplo n.º 11
0
 public void Merge(ReportResult result, bool updateCounts)
 {
     foreach (ReportAssembly assembly in result.Assemblies)
     {
         this.Assemblies.AddReportAssembly(assembly);
     }
     if (updateCounts)
     {
         this.UpdateCounts();
     }
 }
		public void Render(ReportResult result, ITeamCityMessageProvider messageProvider)
		{
			foreach (ReportAssembly reportAssembly in result.Assemblies)
			{
				messageProvider.TestSuiteStarted(reportAssembly.Name);

				foreach (ReportNamespace reportNamespace in reportAssembly.Namespaces)
				{
					RecurseNameSpaces(reportNamespace, messageProvider);
				}

				messageProvider.TestSuiteFinished(reportAssembly.Name);
			}
		}
Exemplo n.º 13
0
 public static ReportResultExplorer Load(string fileName)
 {
     try
     {
         using (StreamReader reader = new StreamReader(fileName))
         {
             XmlSerializer ser = new XmlSerializer(typeof(ReportResult));
             ReportResult result = ser.Deserialize(reader) as ReportResult;
             return new ReportResultExplorer(result);
         }
     }
     catch (Exception)
     {
         ReportResult result = new ReportResult();
         return new ReportResultExplorer(result);
     }
 }
Exemplo n.º 14
0
 public static ReportResultExplorer Load(string fileName)
 {
     try
     {
         using (StreamReader reader = new StreamReader(fileName))
         {
             XmlSerializer ser    = new XmlSerializer(typeof(ReportResult));
             ReportResult  result = ser.Deserialize(reader) as ReportResult;
             return(new ReportResultExplorer(result));
         }
     }
     catch (Exception)
     {
         ReportResult result = new ReportResult();
         return(new ReportResultExplorer(result));
     }
 }
Exemplo n.º 15
0
        public static string RenderToHtml(ReportResult result, string outputPath, string nameFormat)
        {
            if (result == null)
                throw new ArgumentNullException("result");
            if (nameFormat == null)
                throw new ArgumentNullException("nameFormat");
            if (nameFormat.Length == 0)
                throw new ArgumentException("Length is zero", "nameFormat");

            HtmlReport htmlReport = new HtmlReport();

            outputPath = GetAppDataPath(outputPath);

            ResourceHelper.CreateImages(outputPath);

            return htmlReport.Render(result, outputPath, nameFormat);
        }
Exemplo n.º 16
0
        public static string RenderToXml(ReportResult result, string outputPath, string transform, string nameFormat)
        {
            if (result == null)
                throw new ArgumentNullException("result");
            if (nameFormat == null)
                throw new ArgumentNullException("nameFormat");
            if (nameFormat.Length == 0)
                throw new ArgumentException("Length is zero", "nameFormat");

            XmlReport xmlReport = new XmlReport();
            if (transform != null)
            {
                if (!File.Exists(transform))
                    throw new ArgumentException("Transform does not exist.", "transform");
                XslTransform xsl = new XslTransform();
                xsl.Load(transform);
                xmlReport.Transform = xsl;
            }
            return xmlReport.Render(result, outputPath, nameFormat);
        }
Exemplo n.º 17
0
 public override void Render(ReportResult result, TextWriter writer)
 {
     // create xml report and render
     XmlTextWriter output = new XmlTextWriter(writer);
     if (transform != null)
     {
         StringWriter xmlWriter = new StringWriter();
         serializer.Serialize(xmlWriter, result);
         
         // load xslt
         XmlDocument doc = new XmlDocument();
         doc.LoadXml(xmlWriter.ToString());
         transform.Transform(doc, new XsltArgumentList(), output);
     }
     else
     {
         serializer.Serialize(output, result);
     }
     output.Flush();
     output.Close();
 }
Exemplo n.º 18
0
		protected virtual string GetFileName(
            ReportResult result, 
            string outputPath, 
            string nameFormat, 
            string extension) 
        {
            if (result == null)
                throw new ArgumentNullException("result");
            if (nameFormat == null)
                throw new ArgumentNullException("nameFormat");
            if (nameFormat.Length==0)
                throw new ArgumentException("Length is 0","nameFormat");
            if (extension == null)
                throw new ArgumentNullException("extension");
            if (extension.Length == 0)
                throw new ArgumentException("Length is 0", "extension");

            string outputFileName = String.Format(nameFormat + extension
				, result.Date.ToShortDateString()
				, result.Date.ToLongTimeString()
				);

            outputFileName = outputFileName
                                .Replace('/', '_')
                                .Replace('\\', '_')
                                .Replace(':', '_')
                                .Replace(' ', '_');

            outputPath = GetAppDataPath(outputPath);

            DirectoryCheckCreate(outputPath);

            outputFileName = Path.Combine(outputPath, outputFileName);

            return outputFileName;
		}
Exemplo n.º 19
0
 public void Clear()
 {
     this.assemblies.Clear();
     this.fixtures.Clear();
     this.result = null;
 }
Exemplo n.º 20
0
        public void LoadAndRunFixtures()
        {
            this.CreateAssembly();

            // load assembly
            using(TestDomain domain = new TestDomain(this.compiler.Parameters.OutputAssembly))
            {
                domain.ShadowCopyFiles = false;
                domain.InitializeEngine();
                foreach (string dir in this.Compiler.Parameters.ReferencedAssemblies)
                    domain.TestEngine.AddHintDirectory(dir);
                domain.PopulateEngine();
                Console.WriteLine("Domain loaded");
                Console.WriteLine("Tree populated, {0} tests", domain.TestEngine.GetTestCount());
                // Assert.AreEqual(1, domain.TestTree.GetTestCount());
                // domain.TestTree.Success+=new MbUnit.Core.RunSuccessEventHandler(TestTree_Success);
                // running tests
                domain.TestEngine.RunPipes();

                // display report
                TextReport report = new TextReport();
                result = domain.TestEngine.Report.Result;
                report.Render(result,Console.Out);
                counter = domain.TestEngine.GetTestCount();
            }
        }
        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;
        }
Exemplo n.º 22
0
 public virtual string Render(ReportResult result)
 {
     bool isProfiling = Environment.GetEnvironmentVariable("cor_enable_profiling") == "1";
     if (!isProfiling)
     {
         if (result == null)
             throw new ArgumentNullException("result");
         return Render(result, "", null);
     }
     else
     {
         return "";
     }
 }
Exemplo n.º 23
0
        private void GenerateReports(ITestListener testListener, Assembly assembly,ReportResult result)
        {
            try
            {
                string outputPath = GetAppDataPath("");
                string nameFormat = assembly.GetName().Name + ".Tests";

                string file = HtmlReport.RenderToHtml(result, outputPath, nameFormat);

                if (file != "")
                {
                    Uri uri = new Uri("file:" + Path.GetFullPath(file).Replace("\\", "/"));
                    testListener.TestResultsUrl(uri.AbsoluteUri);
                }
                else
                {
                    testListener.WriteLine("Skipping report generation", Category.Info);
                }
            }
            catch (Exception ex)
            {
                testListener.WriteLine("failed to create reports",Category.Error);
                testListener.WriteLine(ex.ToString(), Category.Error);
            }
        }
        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("etting 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;
        }
Exemplo n.º 25
0
		public void Merge(ReportResult result)
		{
			Merge(result,true);
		}
Exemplo n.º 26
0
 private void GenerateReport(MainArguments parsedArgs, ReportResult result)
 {
     result.UpdateCounts();
     if (parsedArgs.ReportTypes != null && parsedArgs.ReportTypes.Length > 0)
     {
         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.ReportNameFormat);
                     consoleOut.WriteLine("[info] Created xml report {0}", outputPath);
                     break;
                 case ReportType.Html:
                     outputPath = HtmlReport.RenderToHtml(result, parsedArgs.ReportFolder, parsedArgs.ReportNameFormat);
                     consoleOut.WriteLine("[info] Created Html report {0}", outputPath);
                     break;
                 case ReportType.Text:
                     outputPath = TextReport.RenderToText(result, parsedArgs.ReportFolder, 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);
         }
     }
 }
Exemplo n.º 27
0
        public int Main()
        {
            consoleOut.WriteLine("Start time: {0}", DateTime.Now.ToShortTimeString());
            // add path
            foreach (string assemblyPath in this.Arguments.AssemblyPath)
                this.resolver.AddHintDirectory(assemblyPath);

            // store real console
            listener.Writer = Console.Out;
            timer.Start();
            try
            {
                ReportResult result = new ReportResult();
                IFixtureFilter filter = arguments.GetFilter();

                if (this.Arguments.Files.Length == 0)
                {
                    consoleOut.WriteLine("[warning] No test assemblies to execute");
                }
                else
                {
                    consoleOut.WriteLine("[info] Loading test assemblies");
                    using (
                        TestDomainDependencyGraph graph =
                        TestDomainDependencyGraph.BuildGraph(
                            this.Arguments.Files,
                            this.Arguments.AssemblyPath,
                            filter, this.Arguments.Verbose))
                    {
                        //define an assembly resolver routine in case the CLR cannot find our assemblies.
                        AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(AssemblyResolveHandler);

                        graph.Log += new ErrorReporter(graph_Log);
                        consoleOut.WriteLine("[info] Starting execution");
                        ReportResult r = graph.RunTests();
                        graph.Log -= new ErrorReporter(graph_Log);
                        result.Merge(r);
                    }
                }

                this.GenerateReport(arguments, result);
                timer.Stop();
                consoleOut.WriteLine("[info] MbUnit execution finished in {0}s.", timer.Duration);
            return (0==result.Counter.FailureCount) ? 0 : -1;
            }
            catch (Exception ex)
            {
                consoleOut.WriteLine(ex.ToString());
            return -3;
            }
        }
Exemplo n.º 28
0
		public static string RenderToDox(ReportResult result, string outputPath)
		{
			return RenderToDox(result, outputPath, "mbunit-result-dox-{0}{1}");
		}
Exemplo n.º 29
0
		public static string RenderToDox(ReportResult result)
		{
			return RenderToDox(result,"");
		}
Exemplo n.º 30
0
 public override void Render(ReportResult result, TextWriter writer)
 {
     base.Transform = ResourceHelper.ReportHtmlTransform;
     base.Render(result, writer);
 }
Exemplo n.º 31
0
		/// <summary>
		/// Render the report result to the specified writer
		/// </summary>
		/// <param name="result">Result from the test</param>
		/// <param name="writer">Writer to write result output to</param>
		public abstract void Render(ReportResult result, TextWriter writer);
Exemplo n.º 32
0
		/// <summary>
		/// Render the report result to a file 
		/// </summary>
		/// <param name="result">Result from the test</param>
		/// <param name="fileName">Report output file name </param>
		public virtual void Render(ReportResult result, string fileName)
		{
              bool isProfiling = Environment.GetEnvironmentVariable("cor_enable_profiling") == "1";
              if (!isProfiling)
              {
                  if (result == null)
                      throw new ArgumentNullException("result");
                  if (fileName == null)
                      throw new ArgumentNullException("fileName");
                  if (fileName.Length == 0)
                      throw new ArgumentException("Length is 0", "fileName");

                  using (StreamWriter writer = new StreamWriter(fileName))
                  {
                      // this will create a UTF-8 format with no preamble. 
                      // We might need to change that if it create a problem with internationalization
                      Render(result, writer);
                  }
              }
		}
Exemplo n.º 33
0
		/// <summary>
		/// Render the report result to a file 
		/// </summary>
		/// <param name="result">Result from the test</param>
		/// <param name="outputPath">Output directory</param>
		/// <param name="nameFormat">Default format name</param>
		/// <param name="extension">Extension of the file</param>
		/// <returns>File name of the report</returns>
		public virtual string Render(ReportResult result, string outputPath, string nameFormat, string extension)
		{
             bool isProfiling = Environment.GetEnvironmentVariable("cor_enable_profiling") == "1";
             if (!isProfiling)
             {
                 if (result == null)
                     throw new ArgumentNullException("result");
                 if (nameFormat == null)
                     throw new ArgumentNullException("nameFormat");
                 if (nameFormat.Length == 0)
                     throw new ArgumentException("Length is 0", "nameFormat");
                 if (extension == null)
                     throw new ArgumentNullException("extension");
                 if (extension.Length == 0)
                     throw new ArgumentException("Length is 0", "extension");

                 string fileName = GetFileName(result, outputPath, nameFormat, extension);
                 Render(result, fileName);
                 return fileName;
             }
             else
             {
                 return "";
             }

		}
Exemplo n.º 34
0
        static TestRunState toTestRunState(ReportResult reportResult)
        {
            if (reportResult.Counter.FailureCount > 0)
            {
                return TestRunState.Failure;
            }

            if (reportResult.Counter.RunCount > 0)
            {
                return TestRunState.Success;
            }

            return TestRunState.NoTests;
        }
Exemplo n.º 35
0
		/// <summary>
		/// Render the report result to a file 
		/// </summary>
		/// <param name="result">Result from the test</param>
		/// <param name="outputPath">Output directory</param>
		/// <param name="nameFormat">Default format name. If null, the default name will be used</param>
		/// <returns>File name of the report</returns>
		public virtual string Render(ReportResult result, string outputPath, string nameFormat)
		{
            bool isProfiling = Environment.GetEnvironmentVariable("cor_enable_profiling") == "1";
            if (!isProfiling)
            {
                if (result == null)
                    throw new ArgumentNullException("result");

                if (nameFormat == null)
                    nameFormat = DefaultNameFormat;
                return Render(result, outputPath, nameFormat, DefaultExtension);
            }
            else
            {
                return "";
            }
		}
Exemplo n.º 36
0
 public void Clear()
 {
     this.assemblies.Clear();
     this.fixtures.Clear();
     this.result=null;
 }
Exemplo n.º 37
0
 public void Merge(ReportResult result)
 {
     Merge(result, true);
 }