Exemplo n.º 1
0
        /// <summary>
        /// Generate HTML report files from the test runs database.
        /// </summary>
        /// <param name="testRunDatabase">Test runs database.</param>
        public void Generate(TestRunsDatabase testRunDatabase)
        {
            // copy the CSS file to the reports directory
            string cssFileFullPath = settings.CssFileName;

            if (false == Path.IsPathRooted(cssFileFullPath))
            {
                cssFileFullPath = Path.Combine(settings.TemplatesDirectory, cssFileFullPath);
            }

            string cssCopiedPath = Path.Combine(settings.OutputDirectory, Path.GetFileName(cssFileFullPath));

            // make sure the path exists
            AccipioHelper.EnsureDirectoryPathExists(cssCopiedPath, true);

            File.Copy(cssFileFullPath, cssCopiedPath, true);

            FileVersionInfo version = System.Diagnostics.FileVersionInfo.GetVersionInfo(
                System.Reflection.Assembly.GetExecutingAssembly().Location);
            string accipioVersion = version.FileVersion;

            string testCasesHistoryGraphFileName   = "TestCasesHistoyGraph.png";
            string userStoriesHistoryGraphFileName = "UserStoriesHistoyGraph.png";

            Hashtable context = new Hashtable();

            context.Add("db", testRunDatabase);
            context.Add("accipioVersion", accipioVersion);
            context.Add("testCasesGraphFileName", testCasesHistoryGraphFileName);
            context.Add("userStoriesGraphFileName", userStoriesHistoryGraphFileName);

            GenerateReportFile(
                "TestRunsHistory.htm",
                "TestRunsHistory.vm.htm",
                context);

            foreach (TestRun testRun in testRunDatabase.TestRuns)
            {
                context["testRun"] = testRun;
                GenerateReportFile(
                    @"TestRuns/$testRun.FileName",
                    "TestRunReport.vm.htm",
                    context);
            }

            foreach (ITestReportGraphDataGenerator generator in graphDataGenerators)
            {
                TestReportGraphData graphData = generator.GenerateData(testRunDatabase);
                graphGenerator.GenerateGraph(graphData, settings);
            }
        }
        public TestReportGraphData GenerateData(TestRunsDatabase testRunsDatabase)
        {
            TestReportGraphData graphData = new TestReportGraphData("user stories", "UserStoriesHistoyGraph.png");

            graphData.AddSeries("successful", "#75FF47");
            graphData.AddSeries("failed", "#FF6B90");
            graphData.AddSeries("not implemented", "#FFFCA8");

            foreach (TestRun testRun in testRunsDatabase.TestRuns)
            {
                graphData.AddDataValue("successful", testRun.UserStoriesSuccess);
                graphData.AddDataValue("failed", testRun.UserStoriesFail);
                graphData.AddDataValue("not implemented", testRun.UserStoriesNotImplemented);
            }

            return(graphData);
        }
        public int Execute(IEnumerable <string> args)
        {
            List <string> unhandledArguments = options.Parse(args);

            if (unhandledArguments.Count > 0)
            {
                throw new ArgumentException("There are some unsupported options.");
            }

            TestRunsDatabase db = new TestRunsDatabase();

            db.LoadDatabase(testReportsDir, @"AccipioTestLog_*.xml");

            HtmlTestReportGenerator generator = new HtmlTestReportGenerator(settings);

            generator.Generate(db);

            return(0);
        }
Exemplo n.º 4
0
        public void GenerateHtmlReportFile()
        {
            TestRunsDatabase db = new TestRunsDatabase();

            db.LoadDatabase(@"..\..\..\Data\Samples\", @"TestResults.xml");

            for (int i = 0; i < 20; i++)
            {
                db.TestRuns.Add(db.TestRuns[0]);
            }

            HtmlTestReportGeneratorSettings settings = new HtmlTestReportGeneratorSettings("TestProject");

            settings.OutputDirectory    = "reports";
            settings.TemplatesDirectory = @"../../../Accipio/Templates/TestReports";

            HtmlTestReportGenerator generator = new HtmlTestReportGenerator(settings);

            generator.Generate(db);
        }