public void AddScenarios() { var feature = GherkinParser.Parse(FileFullPath); FeatureClass = string.Join("", feature.Name.Split(' ').ToList().Select(y => y.Substring(0, 1).ToUpper() + y.Substring(1))) + "Feature"; Scenarios.AddRange(feature.ScenarioDefinitions.Select(x => new ParsedScenario { Tags = feature.Tags.ToList().Concat(x.Tags.ToList()).Distinct(new TagEqualityComparer()).Select(y => y.Name), MethodName = string.Join("", x.Name.Split(' ').ToList().Select(y => y.Substring(0, 1).ToUpper() + y.Substring(1))), Description = x.Steps.Select(y => y.Keyword + " " + y.Text).ToList(), Examples = RetrieveExamples(x) })); }
public async Task Execute_WhenFieldNameCaseIsDifferent_ThenTestIsSuccessfullyExecuted() { // Arrange string dataSetName = "Test Dataset"; string fieldName = "URN"; string calcName = "Test Calc"; string gherkin = $"Given the dataset '{dataSetName}' field '{fieldName.ToLower()}' is equal to '100050'\n\nThen the result for '{calcName}' is greater than '12' "; ICodeMetadataGeneratorService codeMetadataGeneratorService = CreateCodeMetadataGeneratorService(); codeMetadataGeneratorService .GetTypeInformation(Arg.Any <byte[]>()) .Returns(new List <TypeInformation> { new TypeInformation { Type = "Calculations", Methods = new List <MethodInformation> { new MethodInformation { FriendlyName = calcName } } }, new TypeInformation { Type = "Datasets", Properties = new List <PropertyInformation> { new PropertyInformation { FriendlyName = dataSetName, Type = "DSType" } } }, new TypeInformation { Type = "DSType", Properties = new List <PropertyInformation> { new PropertyInformation { FriendlyName = fieldName, Type = "String" } } } }); IProviderResultsRepository providerResultsRepository = CreateProviderResultsRepository(); ITestRunnerResiliencePolicies resiliencePolicies = CreateResiliencePolicies(); IStepParserFactory stepParserFactory = new StepParserFactory(codeMetadataGeneratorService, providerResultsRepository, resiliencePolicies); ICalculationsRepository calculationsRepository = CreateCalculationsRepository(); calculationsRepository .GetAssemblyBySpecificationId(Arg.Is("spec1")) .Returns(new byte[1]); ILogger logger = CreateLogger(); GherkinParser gherkinParser = new GherkinParser(stepParserFactory, calculationsRepository, logger); ICacheProvider cacheProvider = CreateCacheProvider(); GherkinExecutor gherkinExecutor = CreateGherkinExecutor(gherkinParser, cacheProvider); ProviderResult providerResult = new ProviderResult { Provider = new ProviderSummary { Id = "prov1" }, CalculationResults = new List <CalculationResult> { new CalculationResult { Calculation = new Common.Models.Reference { Name = calcName }, Value = 14 } } }; IEnumerable <ProviderSourceDataset> datasets = new List <ProviderSourceDataset> { new ProviderSourceDataset { DataRelationship = new Common.Models.Reference { Name = dataSetName }, Current = new ProviderSourceDatasetVersion { Rows = new List <Dictionary <string, object> > { new Dictionary <string, object> { { fieldName, 100050 } } } } } }; IEnumerable <TestScenario> testScenarios = new List <TestScenario> { new TestScenario { Id = "ts1", Name = "Test Scenario 1", SpecificationId = "spec1", Current = new TestScenarioVersion { Gherkin = gherkin } } }; BuildProject buildProject = new BuildProject { Build = new Build() }; // Act IEnumerable <ScenarioResult> scenarioResults = await gherkinExecutor.Execute(providerResult, datasets, testScenarios, buildProject); // Assert scenarioResults .Should() .HaveCount(1); scenarioResults .First().HasErrors .Should() .BeFalse("there should be no errors"); scenarioResults .First().StepsExecuted .Should() .Be(scenarioResults.First().TotalSteps, "all steps should be executed"); }
private static Feature ParseFeature(string featureFilePath) { return(GherkinParser .Parse(Path.Combine(ProjectDirectory, "BDD", "Features", $"{featureFilePath}.feature")) .Feature); }