Beispiel #1
0
        public void AddFeatureFile(string featureFileText)
        {
            var featureFile = new FeatureFileInput(GetFeatureFileName(), featureFileText);

            FeatureFiles.Add(featureFile);
            CurrentFeatureFile = featureFile;
        }
        public void AddFeatureFile(string featureFileText, string featureFileName = null)
        {
            featureFileName = featureFileName ?? GetFeatureFileName();
            var featureFile = new FeatureFileInput(featureFileName, featureFileText);

            FeatureFiles.Add(featureFile);
            CurrentFeatureFile = featureFile;
        }
Beispiel #3
0
        private void GetFeatureFiles()
        {
            var featureFiles = Directory.GetFiles(DirectoryName, "*.feature");

            SquashLogger.Info($"Got {featureFiles.Length} feature files for {DirectoryName}");

            foreach (var file in featureFiles)
            {
                var feature = new SquashFeature(file);
                FeatureFiles.Add(feature);
            }
        }
        private void GenerateTestArtifacts(string projectFilePath)
        {
            var customTool = _options.SpecFlowVersion >= new Version("3.0") ? null : "SpecFlowSingleFileGenerator";

            var featuresFolder = Path.Combine(_options.TargetFolder, "Features");
            var stepDefsFolder = Path.Combine(_options.TargetFolder, "StepDefinitions");

            EnsureEmptyFolder(featuresFolder);
            EnsureEmptyFolder(stepDefsFolder);

            var stepCount      = _options.FeatureFileCount * _options.ScenarioPerFeatureFileCount * 4;
            var assetGenerator = new SpecFlowAssetGenerator(Math.Max(3, stepCount * _options.StepDefinitionPerStepPercent / 100));

            if (_options.AddUnicodeBinding)
            {
                assetGenerator.AddUnicodeSteps();
            }
            if (_options.AddAsyncStep)
            {
                assetGenerator.AddAsyncStep();
            }
            var projectChanger = CreateProjectChanger(projectFilePath);

            for (int i = 0; i < _options.FeatureFileCount; i++)
            {
                var scenarioOutlineCount =
                    _options.ScenarioPerFeatureFileCount * _options.ScenarioOutlinePerScenarioPercent / 100;
                var scenarioCount = _options.ScenarioPerFeatureFileCount - scenarioOutlineCount;
                var filePath      = assetGenerator.GenerateFeatureFile(featuresFolder, scenarioCount, scenarioOutlineCount);
                projectChanger.AddFile(filePath, "None", customTool);
                FeatureFiles.Add(filePath);
            }
            var stepDefClasses = assetGenerator.GenerateStepDefClasses(stepDefsFolder, _options.StepDefPerClassCount);

            foreach (var stepDefClass in stepDefClasses)
            {
                projectChanger.AddFile(stepDefClass, "Compile");
            }
            projectChanger.Save();

            _consoleWriteLine(
                $"Generated {assetGenerator.StepDefCount} step definitions, {_options.FeatureFileCount * _options.ScenarioPerFeatureFileCount} scenarios, {assetGenerator.StepCount} steps, {stepDefClasses.Count} step definition classes, {_options.FeatureFileCount} feature files");
        }