Пример #1
0
        public void AssignValuesToTheScenarioTemplate()
        {
            //Given (Arrange)
            Project p = TestEnvironment.BuildMockProjectWithTest();
            string  scenarioTemplate   = TestEnvironment.MockPath + TestContext.DataRow["ScenarioTemplate"];
            string  featureTemplate    = TestEnvironment.MockPath + TestContext.DataRow["FeatureTemplate"];
            string  testReportTemplate = TestEnvironment.MockPath + TestContext.DataRow["TestReportTemplate"];

            //When (Act)
            Report r = new Report(p);

            r.PrepareReportContent(scenarioTemplate, featureTemplate, testReportTemplate);

            //Then (Assert)
            Assert.IsFalse(p.Error);
            foreach (Feature f in p.Features)
            {
                foreach (Scenario s in f.Scenarios)
                {
                    Assert.IsNotNull(s.ReportContent, "Report content is not pupulated for scenario");
                    Assert.AreNotEqual(-1, s.ReportContent.IndexOf(s.Title), "Title on scenario template is not populated");
                    Assert.AreNotEqual(-1, s.ReportContent.IndexOf(s.Description), "Description on scenario template is not populated");
                    if (s.Passed)
                    {
                        Assert.AreNotEqual(-1, s.ReportContent.IndexOf(resourceMan.Resources.GetString("StringReportYes")), "Passed on scenario template is not populated");
                        Assert.AreEqual(-1, s.ReportContent.IndexOf("[ScenarioErrorDescription]"), "[ScenarioErrorDescription] on scenario template is not deleted from template for scenarios passed");
                    }
                    else
                    {
                        Assert.AreNotEqual(-1, s.ReportContent.IndexOf(resourceMan.Resources.GetString("StringReportNo")), "Passed on scenario template is not populated");
                        Assert.AreNotEqual(-1, s.ReportContent.IndexOf(s.ErrorDescription), "Error description on scenario template is not populated for scenarios not passed");
                    }
                }
            }
        }
Пример #2
0
        public void DetectIfTheTestReportTemplateExists()
        {
            //Given (Arrange)
            string validScenarioFileName     = TestEnvironment.MockPath + @"HtmlTestReport\ReportTemplates\Scenario.arepa";
            string validFeatureFileName      = TestEnvironment.MockPath + @"HtmlTestReport\ReportTemplates\Feature.arepa";
            string invalidTestReportFileName = TestEnvironment.MockPath + @"InvalidFile.arepa";

            //When (Act)
            Project p   = TestEnvironment.BuildMockProjectWithTest();
            Report  r   = new Report(p);
            Message msg = null;

            r.MessageRaised += delegate(object sender, MessageEventArgs e)
            {
                msg = e.MsgRaised;
            };
            string reportContent = r.PrepareReportContent(validScenarioFileName, validFeatureFileName, invalidTestReportFileName);

            //Then (Assert)
            Assert.IsTrue(string.IsNullOrEmpty(reportContent));
            Assert.IsTrue(p.Error);
            Assert.AreEqual(MessageType.Error, msg.TypeMessage);
            //Ensures it is picking the right error message
            Regex s = new Regex(TestEnvironment.PrepareStringForRegularExpression(resourceMan.Resources.GetString("StringErrorReportTemplateNotFound"), true));

            Assert.IsTrue(s.IsMatch(msg.Description));
        }
Пример #3
0
        public void ReplaceKeyLabelsDefinedMutipleTimeOnTemplateWithTheRightValue()
        {
            //Given (Arrange)
            Project p = TestEnvironment.BuildMockProjectWithTest();
            string  scenarioTemplate   = TestEnvironment.MockPath + @"HtmlTestReport\ReportTemplates\ScenarioWithKeyRepeated.arepa";
            string  featureTemplate    = TestEnvironment.MockPath + @"HtmlTestReport\ReportTemplates\FeatureWithKeyRepeated.arepa";
            string  testReportTemplate = TestEnvironment.MockPath + @"HtmlTestReport\ReportTemplates\TestReportWithKeyRepeated.arepa";

            //When (Act)
            Report r = new Report(p);

            r.PrepareReportContent(scenarioTemplate, featureTemplate, testReportTemplate);

            //Then (Assert)
            string errorMessage = "Key labels are not replaced properly when it is defined more than once on templates";

            Assert.IsFalse(p.Error);
            Assert.AreEqual(-1, p.ReportContent.IndexOf("[ProjectName]"), errorMessage);
            Assert.AreEqual(-1, p.ReportContent.IndexOf("[ProjectDescription]"), errorMessage);
            Assert.AreEqual(-1, p.ReportContent.IndexOf("[SummaryTotalFeatures]"), errorMessage);
            Assert.AreEqual(-1, p.ReportContent.IndexOf("[SummaryTotalScenarios]"), errorMessage);
            Assert.AreEqual(-1, p.ReportContent.IndexOf("[SummaryScenariosPassed]"), errorMessage);
            Assert.AreEqual(-1, p.ReportContent.IndexOf("[SummarySuccessRate]"), errorMessage);
            Assert.AreEqual(-1, p.ReportContent.IndexOf("[FeatureSection]"), errorMessage);
            Assert.AreEqual(-1, p.ReportContent.IndexOf("[CreationDate]"), errorMessage);
            Assert.AreEqual(-1, p.ReportContent.IndexOf("[CreationTime]"), errorMessage);

            foreach (Feature f in p.Features)
            {
                Assert.AreEqual(-1, f.ReportContent.IndexOf("[FeatureTitle]"), errorMessage);
                Assert.AreEqual(-1, f.ReportContent.IndexOf("[FeatureUserStory]"), errorMessage);
                Assert.AreEqual(-1, f.ReportContent.IndexOf("[FeatureTotalScenarios]"), errorMessage);
                Assert.AreEqual(-1, f.ReportContent.IndexOf("[FeatureScenariosPassed]"), errorMessage);
                Assert.AreEqual(-1, f.ReportContent.IndexOf("[FeatureSuccessRate]"), errorMessage);
                Assert.AreEqual(-1, f.ReportContent.IndexOf("[ScenarioSection]"), errorMessage);

                foreach (Scenario s in f.Scenarios)
                {
                    Assert.AreEqual(-1, s.ReportContent.IndexOf("[ScenarioTitle]"), errorMessage);
                    Assert.AreEqual(-1, s.ReportContent.IndexOf("[ScenarioDescription]"), errorMessage);
                    Assert.AreEqual(-1, s.ReportContent.IndexOf("[ScenarioPassed]"), errorMessage);
                    Assert.AreEqual(-1, s.ReportContent.IndexOf("[ScenarioErrorDescription]"), errorMessage);
                }
            }
        }
Пример #4
0
        public void AssignValuesToTheFeatureTemplate()
        {
            //Given (Arrange)
            Project p = TestEnvironment.BuildMockProjectWithTest();
            string  scenarioTemplate   = TestEnvironment.MockPath + TestContext.DataRow["ScenarioTemplate"];
            string  featureTemplate    = TestEnvironment.MockPath + TestContext.DataRow["FeatureTemplate"];
            string  testReportTemplate = TestEnvironment.MockPath + TestContext.DataRow["TestReportTemplate"];

            //When (Act)
            Report r = new Report(p);

            r.PrepareReportContent(scenarioTemplate, featureTemplate, testReportTemplate);

            //Then (Assert)
            Assert.IsFalse(p.Error);
            foreach (Feature f in p.Features)
            {
                Assert.IsNotNull(f.ReportContent, "Report content is not populated for feature");
                Assert.AreNotEqual(-1, f.ReportContent.IndexOf(f.Title), "Title on feature template is not populated");
                Assert.AreNotEqual(-1, f.ReportContent.IndexOf(f.UserStory), "User story on feature template is not populated");
                Assert.AreNotEqual(-1, f.ReportContent.IndexOf(f.Scenarios.Count.ToString()), "Total scenarios on feature template are not populated");
                Assert.AreNotEqual(-1, f.ReportContent.IndexOf(f.Scenarios.Where(x => x.Passed == true).ToList <Scenario>().Count.ToString()), "Total scenarios passed on feature template are not populated");
                int percentage = Convert.ToInt32((f.Scenarios.Where(x => x.Passed == true).ToList <Scenario>().Count * 100) / f.Scenarios.Count);
                Assert.AreNotEqual(-1, f.ReportContent.IndexOf(percentage + "%"), "Success rate on feature template are not populated");

                if (featureTemplate.EndsWith("FeatureWithoutScenarioSection.arepa"))
                {
                    //Confirm if scenarios where not pupulated for a template without scenariosection
                    //Confirm if scenario seccion was populated
                    foreach (Scenario s in f.Scenarios)
                    {
                        Assert.AreEqual(-1, f.ReportContent.IndexOf(s.Title), "Scenarios are populated on feature template without [scenariosection]");
                    }
                }
                else
                {
                    //Confirm if scenario seccion was populated
                    foreach (Scenario s in f.Scenarios)
                    {
                        Assert.AreNotEqual(-1, f.ReportContent.IndexOf(s.Title), "Scenarios are not populated on feature template with [scenariosection]");
                    }
                }
            }
        }
Пример #5
0
        public void AssignValuesToTheTestReportTemplate()
        {
            //Given (Arrange)
            Project p = TestEnvironment.BuildMockProjectWithTest();
            string  scenarioTemplate   = TestEnvironment.MockPath + TestContext.DataRow["ScenarioTemplate"];
            string  featureTemplate    = TestEnvironment.MockPath + TestContext.DataRow["FeatureTemplate"];
            string  testReportTemplate = TestEnvironment.MockPath + TestContext.DataRow["TestReportTemplate"];

            //When (Act)
            Report r = new Report(p);

            r.PrepareReportContent(scenarioTemplate, featureTemplate, testReportTemplate);

            //Then (Assert)
            Assert.IsFalse(p.Error);
            Assert.IsNotNull(p.ReportContent, "Report content is not populated for Test Report");
            Assert.AreNotEqual(-1, p.ReportContent.IndexOf(p.Name), "Name on test report template is not populated");
            Assert.AreNotEqual(-1, p.ReportContent.IndexOf(p.Description), "Description on test report template is not populated");
            Assert.AreNotEqual(-1, p.ReportContent.IndexOf(p.Features.Count().ToString()), "Total features on test report template is not populated");
            int totalScenarios       = 0;
            int totalScenariosPassed = 0;

            foreach (Feature f in p.Features)
            {
                totalScenarios       += f.Scenarios.Count;
                totalScenariosPassed += f.Scenarios.Where(x => x.Passed).ToList <Scenario>().Count;
                if (testReportTemplate.EndsWith("TestReportWithoutFeatureSection.arepa"))
                {
                    Assert.AreEqual(-1, p.ReportContent.IndexOf(f.Title), "Features are populated on test report template without [featuresection]");
                }
                else
                {
                    Assert.AreNotEqual(-1, p.ReportContent.IndexOf(f.Title), "Features are not populated on test report template with [featuresection]");
                }
            }

            Assert.AreNotEqual(-1, p.ReportContent.IndexOf(totalScenarios.ToString()), "Total scenarios on test report template is not populated");
            Assert.AreNotEqual(-1, p.ReportContent.IndexOf(totalScenariosPassed.ToString()), "Total scenarios passed on test report template is not populated");
            Assert.AreNotEqual(-1, p.ReportContent.IndexOf(((totalScenariosPassed * 100) / totalScenarios).ToString() + "%"), "Summary success rate on test report template is not populated");
            //Confirm creation date and time were replaced
            Assert.AreEqual(-1, p.ReportContent.IndexOf("[CreationDate]"));
            Assert.AreEqual(-1, p.ReportContent.IndexOf("[CreationTime]"));
        }
Пример #6
0
        public void ConfirmTheReportFileNameWasGeneratedWithTheRightName()
        {
            //Given (Arrange)
            Project p = TestEnvironment.BuildMockProjectWithTest();
            string  scenarioTemplate   = TestEnvironment.MockPath + @"HtmlTestReport\ReportTemplates\Scenario.arepa";
            string  featureTemplate    = TestEnvironment.MockPath + @"HtmlTestReport\ReportTemplates\Feature.arepa";
            string  testReportTemplate = TestEnvironment.MockPath + @"HtmlTestReport\ReportTemplates\TestReport.arepa";

            //When (Act)
            Report r              = new Report(p);
            string reportContent  = r.PrepareReportContent(scenarioTemplate, featureTemplate, testReportTemplate);
            string reportFileName = r.SaveReportOnDisc(reportContent, string.Empty);

            //Cleaning test up
            File.Delete(reportFileName);

            //Then (Assert)
            Assert.IsTrue(reportFileName.Contains("ArepaReport_Arepatest_"));
            string date = DateTime.Now.Year + "-" + DateTime.Now.Month + "-" + DateTime.Now.Day;

            Assert.IsTrue(reportFileName.Contains(date));
        }