Esempio n. 1
0
        public FeatureFile(string fileName, Folder folder, Feature feature)
            : base(fileName, folder)
        {
            if (feature == null) throw new ArgumentNullException("feature");

            mContent = feature;
        }
Esempio n. 2
0
 private XElement GetFeatureElement(Feature feature)
 {
     return resultsDocument
                .Descendants("test-suite")
                .Where(x => x.Attribute("description") != null)
                .FirstOrDefault(x => x.Attribute("description").Value == feature.Name);
 }
Esempio n. 3
0
 public FeatureDirectoryTreeNode(FileSystemInfo location, string relativePathFromRoot, Feature feature)
 {
     this.OriginalLocation = location;
     this.OriginalLocationUrl = location.ToUri();
     this.RelativePathFromRoot = relativePathFromRoot;
     this.Feature = feature;
 }
        public void ThenCanReadScenarioOutlineResultSuccessfully()
        {
            // Write out the embedded test results file
            using (var input = new StreamReader(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("Pickles.Test." + RESULTS_FILE_NAME)))
            using (var output = new StreamWriter(RESULTS_FILE_NAME))
            {
                output.Write(input.ReadToEnd());
            }

            var configuration = Kernel.Get<Configuration>();
            configuration.TestResultsFile = new FileInfo(RESULTS_FILE_NAME);

            var results = Kernel.Get<XUnitResults>();

            var feature = new Feature { Name = "Addition" };

            var scenarioOutline = new ScenarioOutline { Name = "Adding several numbers", Feature = feature };
            var result = results.GetScenarioOutlineResult(scenarioOutline);

            result.WasExecuted.ShouldBeTrue();
            result.WasSuccessful.ShouldBeTrue();

            var exampleResult1 = results.GetExampleResult(scenarioOutline, new string[] { "40", "50", "90" });
            exampleResult1.WasExecuted.ShouldBeTrue();
            exampleResult1.WasSuccessful.ShouldBeTrue();

            var exampleResult2 = results.GetExampleResult(scenarioOutline, new string[] { "60", "70", "130" });
            exampleResult2.WasExecuted.ShouldBeTrue();
            exampleResult2.WasSuccessful.ShouldBeTrue();
        }
        public void ThenCanReadScenarioResultSuccessfully()
        {
            // Write out the embedded test results file
            using (var input = new StreamReader(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("Pickles.Test." + RESULTS_FILE_NAME)))
            using (var output = new StreamWriter(RESULTS_FILE_NAME))
            {
                output.Write(input.ReadToEnd());
            }

            var configuration = Kernel.Get<Configuration>();
            configuration.TestResultsFile = new FileInfo(RESULTS_FILE_NAME);

            var results = Kernel.Get<XUnitResults>();

            var feature = new Feature { Name = "Addition" };

            var scenario1 = new Scenario { Name = "Add two numbers", Feature = feature };
            var result1 = results.GetScenarioResult(scenario1);

            result1.WasExecuted.ShouldBeTrue();
            result1.WasSuccessful.ShouldBeTrue();

            var scenario2 = new Scenario { Name = "Fail to add two numbers", Feature = feature };
            var result2 = results.GetScenarioResult(scenario2);

            result2.WasExecuted.ShouldBeTrue();
            result2.WasSuccessful.ShouldBeFalse();
        }
Esempio n. 6
0
        public void Format(IXLWorksheet worksheet, Feature feature)
        {
            worksheet.Cell("A1").Style.Font.SetBold();
            worksheet.Cell("A1").Value = feature.Name;
            worksheet.Cell("B2").Value = feature.Description;
            worksheet.Cell("B2").Style.Alignment.WrapText = false;

            var results = testResults.GetFeatureResult(feature);

            if (configuration.HasTestResults && results.WasExecuted)
            {
                worksheet.Cell("A1").Style.Fill.SetBackgroundColor(results.WasSuccessful
                                                                       ? XLColor.AppleGreen
                                                                       : XLColor.CandyAppleRed);
            }

            int row = 4;
            foreach (IFeatureElement featureElement in feature.FeatureElements)
            {
                var scenario = featureElement as Scenario;
                if (scenario != null)
                {
                    excelScenarioFormatter.Format(worksheet, scenario, ref row);
                }

                var scenarioOutline = featureElement as ScenarioOutline;
                if (scenarioOutline != null)
                {
                    excelScenarioOutlineFormatter.Format(worksheet, scenarioOutline, ref row);
                }

                row++;
            }
        }
Esempio n. 7
0
        public XElement Format(Feature feature)
        {
            var div = new XElement(this.xmlns + "div",
                        new XAttribute("id", "feature"),
                        this.htmlImageResultFormatter.Format(feature),
                        new XElement(this.xmlns + "h1", feature.Name),
                        this.htmlDescriptionFormatter.Format(feature.Description)
                    );

            var scenarios = new XElement(this.xmlns + "ul", new XAttribute("id", "scenarios"));
            int id = 0;

            if (feature.Background != null)
            {
                scenarios.Add(this.htmlScenarioFormatter.Format(feature.Background, id++));
            }

            foreach (var scenario in feature.Scenarios)
            {
                scenarios.Add(this.htmlScenarioFormatter.Format(scenario, id++));
            }

            foreach (var scenarioOutline in feature.ScenarioOutlines)
            {
                scenarios.Add(this.htmlScenarioOutlineFormatter.Format(scenarioOutline, id++));
            }

            div.Add(scenarios);

            return div;
        }
Esempio n. 8
0
        public void Constructor_WithFeature_SetsContentProperty()
        {
            var feature = new Feature();

            var featureFile = new FeatureFile("filename.ext", parentFolder, feature);

            featureFile.Content.ShouldEqual(feature);
        }
        public void Setup()
        {
            _testFeature = new Feature { Name = "Test" };
            _featureFileInfo = new FileInfo(Path.Combine(ROOT_PATH, FEATURE_PATH));
            _featureDirectoryNode = new FeatureDirectoryTreeNode(_featureFileInfo, RELATIVE_PATH, _testFeature);

            _featureWithMeta = new FeatureWithMetaInfo(_featureDirectoryNode);

        }
Esempio n. 10
0
        public TestResult GetFeatureResult(Feature feature)
        {
            XElement featureElement = GetFeatureElement(feature);
            int passedCount = int.Parse(featureElement.Attribute("passed").Value);
            int failedCount = int.Parse(featureElement.Attribute("failed").Value);
            int skippedCount = int.Parse(featureElement.Attribute("skipped").Value);

            return GetAggregateResult(passedCount, failedCount, skippedCount);
        }
Esempio n. 11
0
 public void feature(string keyword, string name, string description, int line)
 {
     isInExample = false;
     isFeatureFound = true;
     theFeature = new Feature();
     theFeature.Name = name;
     theFeature.Description = description;
     theFeature.Tags = new List<string>(featureTags);
     featureTags.Clear();
 }
Esempio n. 12
0
        public void ThenCanFormatDescriptionAsMarkdown()
        {
            var configuration = Kernel.Get<Configuration>();
            configuration.TestResultsFile = null;

            var feature = new Feature
                              {
                                  Name = "A feature",
                                  Description =
                                      @"In order to see the description as nice HTML
As a Pickles user
I want to see the descriptions written in markdown rendered as HTML

Introduction
============

This feature should have some markdown elements that get displayed properly

Context
-------

> I really like blockquotes to describe
> to describe text

I also enjoy using lists as well, here are the reasons

- Lists are easy to read
- Lists make my life easier

I also enjoy ordering things

1. This is the first reason
2. This is the second reason"
                              };

            var htmlFeatureFormatter = Kernel.Get<HtmlFeatureFormatter>();
            XElement featureElement = htmlFeatureFormatter.Format(feature);
            XElement description = featureElement.Elements().FirstOrDefault(element => element.Name.LocalName == "div");

            Assert.NotNull(description);
            description.ShouldBeNamed("div");
            description.ShouldBeInInNamespace("http://www.w3.org/1999/xhtml");
            description.ShouldHaveAttribute("class", "description");
            Assert.AreEqual(9, description.Elements().Count());

            description.Elements().ElementAt(0).ShouldBeNamed("p");
            description.Elements().ElementAt(1).ShouldBeNamed("h1");
            description.Elements().ElementAt(2).ShouldBeNamed("p");
            description.Elements().ElementAt(3).ShouldBeNamed("h2");
            description.Elements().ElementAt(4).ShouldBeNamed("blockquote");
            description.Elements().ElementAt(5).ShouldBeNamed("p");
            description.Elements().ElementAt(6).ShouldBeNamed("ul");
            description.Elements().ElementAt(7).ShouldBeNamed("p");
            description.Elements().ElementAt(8).ShouldBeNamed("ol");
        }
Esempio n. 13
0
        public XElement Format(Feature feature)
        {
            if (configuration.HasTestResults)
            {
                TestResult scenarioResult = results.GetFeatureResult(feature);

                return scenarioResult.WasExecuted ? BuildImageElement(scenarioResult) : null;
            }

            return null;
        }
        public XElement Format(Feature feature)
        {
            if (configuration.HasTestResults)
            {
                TestResult scenarioResult = this.results.GetFeatureResult(feature);
                if (!scenarioResult.WasExecuted || !scenarioResult.WasSuccessful) return null;
                return BuildImageElement(scenarioResult);
            }

            return null;
        }
Esempio n. 15
0
        private XElement GetFeatureElement(Feature feature)
        {
            var featureQuery =
                  from clazz in this.resultsDocument.Root.Descendants("class")
                  from test in clazz.Descendants("test")
                  from trait in clazz.Descendants("traits").Descendants("trait")
                  where trait.Attribute("name").Value == "FeatureTitle" && trait.Attribute("value").Value == feature.Name
                  select clazz;

            return featureQuery.FirstOrDefault();
        }
        public void ThenCanCreateSimpleNameSuccessfully()
        {
            var excelSheetNameGenerator = Kernel.Get<ExcelSheetNameGenerator>();
            var feature = new Feature {Name = "A short feature name"};

            string name;
            using (var wb = new XLWorkbook())
            {
                name = excelSheetNameGenerator.GenerateSheetName(wb, feature);
            }

            name.ShouldEqual("ASHORTFEATURENAME");
        }
Esempio n. 17
0
 private static string RemoveUnnecessaryAndIllegalCharacters(Feature feature)
 {
     return feature.Name
         .Replace(" ", string.Empty)
         .Replace("\t", string.Empty)
         .Replace(":", string.Empty)
         .Replace(@"\", string.Empty)
         .Replace("/", string.Empty)
         .Replace("?", string.Empty)
         .Replace("*", string.Empty)
         .Replace("[", string.Empty)
         .Replace("]", string.Empty);
 }
        public void ThenCanShortenLongNameSuccessfully()
        {
            var excelSheetNameGenerator = Kernel.Get<ExcelSheetNameGenerator>();
            var feature = new Feature {Name = "This is a really really long feature name that needs to be shortened"};

            string name;
            using (var wb = new XLWorkbook())
            {
                name = excelSheetNameGenerator.GenerateSheetName(wb, feature);
            }

            name.ShouldEqual("THISISAREALLYREALLYLONGFEATUREN");
        }
Esempio n. 19
0
        public string GenerateSheetName(XLWorkbook workbook, Feature feature)
        {
            string name = RemoveUnnecessaryAndIllegalCharacters(feature).ToUpperInvariant();
            if (name.Length > 31) name = name.Substring(0, 31);

            // check if the workbook contains any sheets with this name
            int nextIndex = 1;
            while (workbook.Worksheets.Any(sheet => sheet.Name == name))
            {
                name = name.Remove(name.Length - 3, 3);
                name = name + "(" + nextIndex++ + ")";
            }

            return name;
        }
        public void Setup()
        {
            _feature = new Feature {Name = "Addition"};

            // Write out the embedded test results file
            using (var input = new StreamReader(Assembly.GetExecutingAssembly().GetManifestResourceStream("Pickles.Test." + RESULTS_FILE_NAME)))
            using (var output = new StreamWriter(RESULTS_FILE_NAME))
            {
                output.Write(input.ReadToEnd());
            }

            var configuration = Kernel.Get<Configuration>();
            configuration.TestResultsFile = new FileInfo(RESULTS_FILE_NAME);

            _results = Kernel.Get<MsTestResults>();
        }
        public void ThenCanShortenLongDuplicatedNameSuccessfully()
        {
            var excelSheetNameGenerator = Kernel.Get<ExcelSheetNameGenerator>();
            var feature1 = new Feature {Name = "This is a really really long feature name that needs to be shortened A"};
            var feature2 = new Feature {Name = "This is a really really long feature name that needs to be shortened B"};

            string name1;
            string name2;
            using (var wb = new XLWorkbook())
            {
                name1 = excelSheetNameGenerator.GenerateSheetName(wb, feature1);
                wb.AddWorksheet(name1);
                name2 = excelSheetNameGenerator.GenerateSheetName(wb, feature2);
            }

            name2.ShouldEqual("THISISAREALLYREALLYLONGFEATU(1)");
        }
        public void ThenCanReadFeatureResultSuccessfully()
        {
            // Write out the embedded test results file
            using (var input = new StreamReader(Assembly.GetExecutingAssembly().GetManifestResourceStream("Pickles.Test." + RESULTS_FILE_NAME)))
            using (var output = new StreamWriter(RESULTS_FILE_NAME))
            {
                output.Write(input.ReadToEnd());
            }

            var configuration = Kernel.Get<Configuration>();
            configuration.TestResultsFile = new FileInfo(RESULTS_FILE_NAME);

            var results = Kernel.Get<XUnitResults>();

            var feature = new Feature {Name = "Addition"};
            TestResult result = results.GetFeatureResult(feature);

            result.WasExecuted.ShouldBeTrue();
            result.WasSuccessful.ShouldBeFalse();
        }
Esempio n. 23
0
        public XElement Format(Feature feature)
        {
            var div = new XElement(xmlns + "div",
                                   new XAttribute("id", "feature"),
                                   htmlImageResultFormatter.Format(feature),
                                   new XElement(xmlns + "h1", feature.Name),
                                   htmlDescriptionFormatter.Format(feature.Description)
                );

            var scenarios = new XElement(xmlns + "ul", new XAttribute("id", "scenarios"));
            int id = 0;

            if (feature.Background != null)
            {
                scenarios.Add(htmlScenarioFormatter.Format(feature.Background, id++));
            }

            foreach (IFeatureElement featureElement in feature.FeatureElements)
            {
                var scenario = featureElement as Scenario;
                if (scenario != null)
                {
                    scenarios.Add(htmlScenarioFormatter.Format(scenario, id++));
                }

                var scenarioOutline = featureElement as ScenarioOutline;
                if (scenarioOutline != null)
                {
                    scenarios.Add(htmlScenarioOutlineFormatter.Format(scenarioOutline, id++));
                }
            }

            div.Add(scenarios);

            return div;
        }
        public void ThenItWillRemoveUnnecessaryAndInvalidCharacters()
        {
            var excelSheetNameGenerator = Kernel.Get<ExcelSheetNameGenerator>();
            var feature = new Feature { Name = @"This Had invalid characters: :\/?*[]" };
            
            string name;
            using (var wb = new XLWorkbook())
            {
                name = excelSheetNameGenerator.GenerateSheetName(wb, feature);
            }

            name.ShouldEqual("THISHASINVALIDCHARACTERS");
        }
Esempio n. 25
0
 public FeatureWithMetaInfo(FeatureDirectoryTreeNode featureNodeTreeNode)
 {
     Feature = featureNodeTreeNode.Feature;
     RelativeFolder = featureNodeTreeNode.RelativePathFromRoot;
 }
Esempio n. 26
0
        public TestResult GetFeatureResult(Feature feature)
        {
            var featureExecutionIds =
                from unitTest in this.resultsDocument.Root.Descendants(ns + "UnitTest")
                let properties = unitTest.Element(ns + "Properties")
                where properties != null
                let property = properties.Element(ns + "Property")
                let key = property.Element(ns + "Key")
                let value = property.Element(ns + "Value")
                where key.Value == "FeatureTitle" && value.Value == feature.Name
                select new Guid(unitTest.Element(ns + "Execution").Attribute("id").Value);

            bool wasExecuted = true;
            bool wasSuccessful = true;
            foreach (Guid featureExecutionId in featureExecutionIds)
            {
                TestResult result = GetExecutionResult(featureExecutionId);
                if (!result.WasExecuted) wasExecuted = false;
                if (!result.WasSuccessful) wasSuccessful = false;
            }

            return new TestResult {WasExecuted = wasExecuted, WasSuccessful = wasSuccessful};
        }
Esempio n. 27
0
 public TestResult GetFeatureResult(Feature feature)
 {
     return new TestResult();
 }
Esempio n. 28
0
 public TestResult GetFeatureResult(Feature feature)
 {
     var featureElement = GetFeatureElement(feature);
     return GetResultFromElement(featureElement);
 }