public FeatureFile(string fileName, Folder folder, Feature feature, IFileSystem fileSystem) : base(fileName, folder, fileSystem) { if (feature == null) throw new ArgumentNullException("feature"); this.mContent = feature; }
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 = this.testResults.GetFeatureResult(feature); if (this.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) { this.excelScenarioFormatter.Format(worksheet, scenario, ref row); } var scenarioOutline = featureElement as ScenarioOutline; if (scenarioOutline != null) { this.excelScenarioOutlineFormatter.Format(worksheet, scenarioOutline, ref row); } row++; } }
public FeatureNode(FileSystemInfoBase 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(Assembly.GetExecutingAssembly().GetManifestResourceStream("PicklesDoc.Pickles.Test." + RESULTS_FILE_NAME))) using (var output = new StreamWriter(RESULTS_FILE_NAME)) { output.Write(input.ReadToEnd()); } var configuration = Container.Resolve<Configuration>(); configuration.TestResultsFile = new FileInfo(RESULTS_FILE_NAME); var results = Container.Resolve<NUnitResults>(); var feature = new Feature {Name = "Addition"}; var scenarioOutline = new ScenarioOutline {Name = "Adding several numbers", Feature = feature}; TestResult result = results.GetScenarioOutlineResult(scenarioOutline); result.WasExecuted.ShouldBeTrue(); result.WasSuccessful.ShouldBeTrue(); TestResult exampleResult1 = results.GetExampleResult(scenarioOutline, new[] {"40", "50", "90"}); exampleResult1.WasExecuted.ShouldBeTrue(); exampleResult1.WasSuccessful.ShouldBeTrue(); TestResult exampleResult2 = results.GetExampleResult(scenarioOutline, new[] {"60", "70", "130"}); exampleResult2.WasExecuted.ShouldBeTrue(); exampleResult2.WasSuccessful.ShouldBeTrue(); }
public void ThenCanReadScenarioResultSuccessfully() { // Write out the embedded test results file using (var input = new StreamReader(Assembly.GetExecutingAssembly().GetManifestResourceStream("PicklesDoc.Pickles.Test." + RESULTS_FILE_NAME))) using (var output = new StreamWriter(RESULTS_FILE_NAME)) { output.Write(input.ReadToEnd()); } var configuration = Container.Resolve<Configuration>(); configuration.TestResultsFile = new FileInfo(RESULTS_FILE_NAME); var results = Container.Resolve<NUnitResults>(); var feature = new Feature {Name = "Addition"}; var scenario1 = new Scenario {Name = "Add two numbers", Feature = feature}; TestResult result1 = results.GetScenarioResult(scenario1); result1.WasExecuted.ShouldBeTrue(); result1.WasSuccessful.ShouldBeTrue(); var scenario2 = new Scenario {Name = "Fail to add two numbers", Feature = feature}; TestResult result2 = results.GetScenarioResult(scenario2); result2.WasExecuted.ShouldBeTrue(); result2.WasSuccessful.ShouldBeFalse(); }
public void Constructor_WithFeature_SetsContentProperty() { var feature = new Feature(); var featureFile = new FeatureFile("filename.ext", parentFolder, feature); featureFile.Content.ShouldEqual(feature); }
public void Setup() { this._testFeature = new Feature { Name = "Test" }; this._featureFileInfo = this.FileSystem.FileInfo.FromFileName(FileSystem.Path.Combine(ROOT_PATH, FEATURE_PATH)); this._featureDirectoryNode = new FeatureNode(this._featureFileInfo, RELATIVE_PATH, this._testFeature); this._featureWithMeta = new FeatureWithMetaInfo(this._featureDirectoryNode); }
public TestResult GetFeatureResult(Feature feature) { var featureElement = this.GetFeatureElement(feature); var results = featureElement.Descendants("test-case") .Select(GetResultFromElement); return results.Merge(); }
public TestResult GetFeatureResult(Feature feature) { XElement featureElement = this.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); }
public void feature(string keyword, string name, string description, int line) { this.isInExample = false; this.isFeatureFound = true; this.theFeature = new Feature(); this.theFeature.Name = name; this.theFeature.Description = description; this.theFeature.Tags = new List<string>(this.featureTags); this.featureTags.Clear(); }
public void ThenCanFormatDescriptionAsMarkdown() { var configuration = Container.Resolve<Configuration>(); configuration.TestResultsFiles = 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 = Container.Resolve<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"); }
public void ThenCanShortenLongNameSuccessfully() { var excelSheetNameGenerator = Container.Resolve<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"); }
public void GetFeatureResult_OnePassingOneFailed_ReturnsPassed() { var feature = new Feature(); var testResults1 = SetupStubForGetFeatureResult(feature, TestResult.Passed); var testResults2 = SetupStubForGetFeatureResult(feature, TestResult.Failed); ITestResults multipleTestResults = CreateMultipleTestResults(testResults1.Object, testResults2.Object); var result = multipleTestResults.GetFeatureResult(feature); result.ShouldEqual(TestResult.Failed); }
public void GetFeatureResult_TwoInconclusive_ReturnsInconclusive() { var feature = new Feature(); var testResults1 = SetupStubForGetFeatureResult(feature, TestResult.Inconclusive); var testResults2 = SetupStubForGetFeatureResult(feature, TestResult.Inconclusive); ITestResults multipleTestResults = CreateMultipleTestResults(testResults1.Object, testResults2.Object); var result = multipleTestResults.GetFeatureResult(feature); result.ShouldEqual(TestResult.Inconclusive); }
public void ThenCanCreateSimpleNameSuccessfully() { var excelSheetNameGenerator = Container.Resolve<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"); }
public TestResult GetFeatureResult(Feature feature) { var featureElement = this.GetFeatureElement(feature); if (featureElement == null) { return TestResult.Inconclusive; } var results = featureElement.Descendants("test-case") .Select(GetResultFromElement); return results.Merge(); }
public TestResult GetFeatureResult(Feature feature) { var featureExecutionIds = from scenario in AllScenariosInResultFile() let properties = PropertiesOf(scenario) where properties != null where FeatureNamePropertyExistsWith(feature.Name, among: properties) select ScenarioExecutionIdOf(scenario); TestResult result = featureExecutionIds.Select(this.GetExecutionResult).Merge(); return result; }
public void ThenCanShortenLongDuplicatedNameSuccessfully() { var excelSheetNameGenerator = Container.Resolve<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 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)); var tags = RetrieveTags(feature); if (tags.Length > 0) { var paragraph = new XElement(this.xmlns + "p", HtmlScenarioFormatter.CreateTagElements(tags.OrderBy(t => t).ToArray(), this.xmlns)); paragraph.Add(new XAttribute("class", "tags")); div.Add(paragraph); } div.Add(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 (IFeatureElement featureElement in feature.FeatureElements) { var scenario = featureElement as Scenario; if (scenario != null) { scenarios.Add(this.htmlScenarioFormatter.Format(scenario, id++)); } var scenarioOutline = featureElement as ScenarioOutline; if (scenarioOutline != null) { scenarios.Add(this.htmlScenarioOutlineFormatter.Format(scenarioOutline, id++)); } } div.Add(scenarios); return div; }
public void Format(IXLWorksheet worksheet, Feature feature) { worksheet.Cell("A1").Style.Font.SetBold(); worksheet.Cell("A1").Value = feature.Name; if (feature.Description.Length <= short.MaxValue) { worksheet.Cell("B2").Value = feature.Description; } else { var description = feature.Description.Substring(0, short.MaxValue); log.Warn("The description of feature {0} was truncated because of cell size limitations in Excel.", feature.Name); worksheet.Cell("B2").Value = description; } worksheet.Cell("B2").Style.Alignment.WrapText = false; var results = this.testResults.GetFeatureResult(feature); if (this.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) { this.excelScenarioFormatter.Format(worksheet, scenario, ref row); } var scenarioOutline = featureElement as ScenarioOutline; if (scenarioOutline != null) { this.excelScenarioOutlineFormatter.Format(worksheet, scenarioOutline, ref row); } row++; } }
public TestResult GetFeatureResult(Gherkin.Feature feature) { if (this.specRunFeatures == null) { return(TestResult.Inconclusive); } var specRunFeature = this.FindSpecRunFeature(feature); if (specRunFeature == null) { return(TestResult.Inconclusive); } TestResult result = specRunFeature.Scenarios.Select(specRunScenario => StringToTestResult(specRunScenario.Result)).Merge(); return(result); }
public void Then_feature_is_added_successfully() { var excelFeatureFormatter = Container.Resolve<ExcelFeatureFormatter>(); var feature = new Feature { Name = "Test Feature", Description = "In order to test this feature,\nAs a developer\nI want to test this feature" }; using (var workbook = new XLWorkbook()) { IXLWorksheet worksheet = workbook.AddWorksheet("SHEET1"); excelFeatureFormatter.Format(worksheet, feature); worksheet.Cell("A1").Value.ShouldEqual(feature.Name); worksheet.Cell("B2").Value.ShouldEqual(feature.Description); } }
public void ThenCanReadFeatureResultSuccesfully() { // Write out the embedded test results file using (var input = new StreamReader(Assembly.GetExecutingAssembly().GetManifestResourceStream("PicklesDoc.Pickles.Test." + RESULTS_FILE_NAME))) using (var output = new StreamWriter(RESULTS_FILE_NAME)) { output.Write(input.ReadToEnd()); } var configuration = Container.Resolve<Configuration>(); configuration.TestResultsFile = new FileInfo(RESULTS_FILE_NAME); var results = Container.Resolve<CucumberJsonResults>(); var feature = new Feature { Name = "Test Feature" }; TestResult result = results.GetFeatureResult(feature); result.WasExecuted.ShouldBeTrue(); result.WasSuccessful.ShouldBeFalse(); }
public void FeatureTagsAreAddedToScenarioTags() { var feature = new Feature { Name = "A Scenario with Tags", FeatureElements = { new Scenario { Name = "A Scenario", Description = @"This scenario has tags", Tags = { "scenarioTag1", "scenarioTag2" } } }, Tags = { "featureTag1", "featureTag2" } }; feature.FeatureElements[0].Feature = feature; var htmlFeatureFormatter = Container.Resolve<HtmlFeatureFormatter>(); XElement featureElement = htmlFeatureFormatter.Format(feature); var header = featureElement.Descendants().First(n => n.Attributes().Any(a => a.Name == "class" && a.Value == "scenario-heading")); Assert.AreEqual(3, header.Elements().Count()); header.Elements().ElementAt(0).ShouldBeNamed("h2"); header.Elements().ElementAt(1).ShouldBeNamed("p"); header.Elements().ElementAt(2).ShouldBeNamed("div"); var tagsParagraph = header.Elements().ElementAt(1); Assert.AreEqual( @"<p class=""tags"" xmlns=""http://www.w3.org/1999/xhtml"">Tags: <span>featureTag1</span>, <span>featureTag2</span>, <span>scenarioTag1</span>, <span>scenarioTag2</span></p>", tagsParagraph.ToString()); }
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); TestResult result = featureExecutionIds.Select(this.GetExecutionResult).Merge(); return result; }
public void ThenItWillRemoveUnnecessaryAndInvalidCharacters() { var excelSheetNameGenerator = Container.Resolve<ExcelSheetNameGenerator>(); var feature = new Feature { Name = @"This Had invalid characters: :\/?*[]" }; string name; using (var wb = new XLWorkbook()) { name = excelSheetNameGenerator.GenerateSheetName(wb, feature); } name.ShouldEqual("THISHADINVALIDCHARACTERS"); }
public TestResult GetFeatureResult(Feature feature) { return new TestResult(); }
private static string[] RetrieveTags(Feature feature) { if (feature == null) return new string[0]; return feature.Tags.ToArray(); }
private XElement GetFeatureElement(Feature feature) { IEnumerable<XElement> 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(); }
private SpecRun.Feature FindSpecRunFeature(Gherkin.Feature feature) { return(this.specRunFeatures.FirstOrDefault(specRunFeature => specRunFeature.Title == feature.Name)); }
private XElement GetFeatureElement(Feature feature) { return this.resultsDocument .Descendants("test-suite") .Where(x => x.Attribute("description") != null) .FirstOrDefault(x => x.Attribute("description").Value == feature.Name); }
public TestResult GetFeatureResult(Feature feature) { var results = this.TestResults.Select(tr => tr.GetFeatureResult(feature)).ToArray(); return EvaluateTestResults(results); }