public GenerationResult GenerateFeatureFile(string featureFilePath, string targetExtension, string targetNamespace) { var projectSettings = _projectScope.GetProjectSettings(); var specFlowToolsFolder = GetSpecFlowToolsFolderSafe(_projectScope, projectSettings, out var toolsFolderErrorMessage); if (specFlowToolsFolder == null) { return(CreateErrorResult(featureFilePath, $"Unable to use SpecFlow tools folder '{projectSettings.SpecFlowGeneratorFolder}': {toolsFolderErrorMessage}")); } var stopwatch = new Stopwatch(); stopwatch.Start(); try { var connector = OutProcSpecFlowConnectorFactory.Create(_projectScope); var result = connector.RunGenerator(featureFilePath, projectSettings.SpecFlowConfigFilePath, targetExtension, targetNamespace, _projectScope.ProjectFolder, specFlowToolsFolder); _projectScope.IdeScope.MonitoringService.MonitorSpecFlowGeneration(result.IsFailed, projectSettings); if (result.IsFailed) { _logger.LogWarning(result.ErrorMessage); SetErrorContent(featureFilePath, result); _logger.LogVerbose(() => result.FeatureFileCodeBehind.Content); } else { _logger.LogInfo($"code-behind file generated for file {featureFilePath} in project {_projectScope.ProjectName}"); _logger.LogVerbose(() => result.FeatureFileCodeBehind.Content.Substring(0, Math.Min(450, result.FeatureFileCodeBehind.Content.Length))); } return(result); } catch (Exception ex) { _logger.LogException(MonitoringService, ex); return(CreateErrorResult(featureFilePath, ex.Message)); } finally { stopwatch.Stop(); _logger.LogVerbose($"Generation: {stopwatch.ElapsedMilliseconds} ms"); } }
private OutProcSpecFlowConnector GetConnector(ProjectSettings projectSettings) { return(OutProcSpecFlowConnectorFactory.Create(_projectScope)); }