public void ProcessProject(SpecFlowProject specFlowProject, bool forceGenerate) { if (verboseOutput) traceWriter.WriteLine("Processing project: " + specFlowProject); SpecFlowGenerator generator = new SpecFlowGenerator(specFlowProject); foreach (var featureFile in specFlowProject.FeatureFiles) { string featureFileFullPath = featureFile.GetFullPath(specFlowProject); string codeFileFullPath = featureFileFullPath + ".cs"; bool needsProcessing = true; if (!forceGenerate && IsUpToDate(generator, featureFileFullPath, codeFileFullPath)) { needsProcessing = false; } if (verboseOutput || needsProcessing) { traceWriter.WriteLine("Processing file: {0}", featureFileFullPath); if (!needsProcessing) traceWriter.WriteLine(" up-to-date"); } if (needsProcessing) { GenerateFile(generator, featureFile, codeFileFullPath); } } }
private static SpecFlowProject LoadSpecFlowProjectFromDteProjectInternal(Project project) { string projectFolder = Path.GetDirectoryName(project.FullName); SpecFlowProject specFlowProject = new SpecFlowProject(); specFlowProject.ProjectFolder = projectFolder; specFlowProject.ProjectName = Path.GetFileNameWithoutExtension(project.FullName); specFlowProject.AssemblyName = project.Properties.Item("AssemblyName").Value as string; specFlowProject.DefaultNamespace = project.Properties.Item("DefaultNamespace").Value as string; foreach (ProjectItem projectItem in VsxHelper.GetAllProjectItem(project).Where(IsPhysicalFile)) { var fileName = GetRelativePath(GetFileName(projectItem), projectFolder); var extension = Path.GetExtension(fileName); if (extension.Equals(".feature", StringComparison.InvariantCultureIgnoreCase)) { var featureFile = new SpecFlowFeatureFile(fileName); var ns = projectItem.Properties.Item("CustomToolNamespace").Value as string; if (!String.IsNullOrEmpty(ns)) featureFile.CustomNamespace = ns; specFlowProject.FeatureFiles.Add(featureFile); } if (Path.GetFileName(fileName).Equals("app.config", StringComparison.InvariantCultureIgnoreCase)) { string configFileContent = GetFileContent(projectItem); GeneratorConfigurationReader.UpdateConfigFromFileContent(specFlowProject.GeneratorConfiguration, configFileContent); RuntimeConfigurationReader.UpdateConfigFromFileContent(specFlowProject.RuntimeConfiguration, configFileContent); } } return specFlowProject; }
private static SpecFlowProject LoadSpecFlowProjectFromDteProjectInternal(Project project) { string projectFolder = Path.GetDirectoryName(project.FullName); SpecFlowProject specFlowProject = new SpecFlowProject(); specFlowProject.ProjectFolder = projectFolder; specFlowProject.ProjectName = Path.GetFileNameWithoutExtension(project.FullName); specFlowProject.AssemblyName = project.Properties.Item("AssemblyName").Value as string; specFlowProject.DefaultNamespace = project.Properties.Item("DefaultNamespace").Value as string; foreach (ProjectItem projectItem in VsxHelper.GetAllPhysicalFileProjectItem(project)) { if (".feature".Equals(Path.GetExtension(projectItem.Name), StringComparison.InvariantCultureIgnoreCase)) { var featureFile = new SpecFlowFeatureFile(VsxHelper.GetProjectRelativePath(projectItem)); var ns = projectItem.Properties.Item("CustomToolNamespace").Value as string; if (!String.IsNullOrEmpty(ns)) featureFile.CustomNamespace = ns; specFlowProject.FeatureFiles.Add(featureFile); } } specFlowProject.Configuration = LoadSpecFlowConfigurationFromDteProjectInternal(project); return specFlowProject; }
public static SpecFlowProject LoadSpecFlowProjectFromMsBuild(string projectFile) { projectFile = Path.GetFullPath(projectFile); Project project = new Project(); project.Load(projectFile, ProjectLoadSettings.IgnoreMissingImports); string projectFolder = Path.GetDirectoryName(projectFile); SpecFlowProject specFlowProject = new SpecFlowProject(); specFlowProject.ProjectFolder = projectFolder; specFlowProject.ProjectName = Path.GetFileNameWithoutExtension(projectFile); specFlowProject.AssemblyName = project.GetEvaluatedProperty("AssemblyName"); specFlowProject.DefaultNamespace = project.GetEvaluatedProperty("RootNamespace"); var items = project.GetEvaluatedItemsByName("None").Cast<BuildItem>() .Concat(project.GetEvaluatedItemsByName("Content").Cast<BuildItem>()); foreach (BuildItem item in items) { var extension = Path.GetExtension(item.FinalItemSpec); if (extension.Equals(".feature", StringComparison.InvariantCultureIgnoreCase)) { var featureFile = new SpecFlowFeatureFile(item.FinalItemSpec); var ns = item.GetEvaluatedMetadata("CustomToolNamespace"); if (!String.IsNullOrEmpty(ns)) featureFile.CustomNamespace = ns; specFlowProject.FeatureFiles.Add(featureFile); } if (Path.GetFileName(item.FinalItemSpec).Equals("app.config", StringComparison.InvariantCultureIgnoreCase)) { GeneratorConfigurationReader.UpdateConfigFromFile(specFlowProject.GeneratorConfiguration, Path.Combine(projectFolder, item.FinalItemSpec)); } } return specFlowProject; }
public StepDefinitionReportGenerator(SpecFlowProject specFlowProject, List<BindingInfo> bindings, List<Feature> parsedFeatures, bool showBindingsWithoutInsance) { this.specFlowProject = specFlowProject; this.showBindingsWithoutInsance = showBindingsWithoutInsance; this.bindings = bindings; this.parsedFeatures = parsedFeatures; }
public StepDefinitionReportGenerator(StepDefinitionReportParameters reportParameters) { ReportParameters = reportParameters; specFlowProject = MsBuildProjectReader.LoadSpecFlowProjectFromMsBuild(reportParameters.ProjectFile); parsedFeatures = ParserHelper.GetParsedFeatures(specFlowProject); var basePath = Path.Combine(specFlowProject.ProjectFolder, reportParameters.BinFolder); bindings = BindingCollector.CollectBindings(specFlowProject, basePath); }
public StepDefinitionReportGenerator(string projectFile, string binFolder, bool showBindingsWithoutInsance) { specFlowProject = MsBuildProjectReader.LoadSpecFlowProjectFromMsBuild(projectFile); parsedFeatures = ParserHelper.GetParsedFeatures(specFlowProject); var basePath = Path.Combine(specFlowProject.ProjectFolder, binFolder); bindings = BindingCollector.CollectBindings(specFlowProject, basePath); this.showBindingsWithoutInsance = showBindingsWithoutInsance; }
public GherkinFileEditorParser(ITextBuffer buffer, IClassificationTypeRegistryService registry, SpecFlowProject specFlowProject) { this.buffer = buffer; this.specFlowProject = specFlowProject; this.buffer.Changed += BufferChanged; this.classifications = new GherkinFileEditorClassifications(registry); // initial parsing ChangeInfo changeInfo = new ChangeInfo(buffer); parsingTask = parsingTaskFactory.StartNew(() => ParseAndTriggerChanges(GherkinFileEditorInfo, changeInfo)); }
public GherkinFileEditorParser(ITextBuffer buffer, IClassificationTypeRegistryService registry, IVisualStudioTracer visualStudioTracer, SpecFlowProject specFlowProject) { this.buffer = buffer; this.visualStudioTracer = visualStudioTracer; this.specFlowProject = specFlowProject; this.buffer.Changed += BufferChanged; this.classifications = new GherkinFileEditorClassifications(registry); // initial parsing visualStudioTracer.Trace("Initial parsing scheduled", ParserTraceCategory); ChangeInfo changeInfo = new ChangeInfo(buffer); parsingTask = parsingTaskFactory.StartNew(() => ParseAndTriggerChanges(GherkinFileEditorInfo, changeInfo)); }
public static SpecFlowProject LoadSpecFlowProjectFromMsBuild(string projectFile) { projectFile = Path.GetFullPath(projectFile); Project project = Engine.GlobalEngine.GetLoadedProject(projectFile); if (project == null) { project = new Project(); project.Load(projectFile, ProjectLoadSettings.IgnoreMissingImports); } string projectFolder = Path.GetDirectoryName(projectFile); SpecFlowProject specFlowProject = new SpecFlowProject(); specFlowProject.ProjectFolder = projectFolder; specFlowProject.ProjectName = Path.GetFileNameWithoutExtension(projectFile); specFlowProject.AssemblyName = project.GetEvaluatedProperty("AssemblyName"); specFlowProject.DefaultNamespace = project.GetEvaluatedProperty("RootNamespace"); var items = project.GetEvaluatedItemsByName("None").Cast <BuildItem>() .Concat(project.GetEvaluatedItemsByName("Content").Cast <BuildItem>()); foreach (BuildItem item in items) { var extension = Path.GetExtension(item.FinalItemSpec); if (extension.Equals(".feature", StringComparison.InvariantCultureIgnoreCase)) { var featureFile = new SpecFlowFeatureFile(item.FinalItemSpec); var ns = item.GetEvaluatedMetadata("CustomToolNamespace"); if (!String.IsNullOrEmpty(ns)) { featureFile.CustomNamespace = ns; } specFlowProject.FeatureFiles.Add(featureFile); } if (Path.GetFileName(item.FinalItemSpec).Equals("app.config", StringComparison.InvariantCultureIgnoreCase)) { GeneratorConfigurationReader.UpdateConfigFromFile(specFlowProject.GeneratorConfiguration, Path.Combine(projectFolder, item.FinalItemSpec)); } } return(specFlowProject); }
internal static List<BindingInfo> CollectBindings(SpecFlowProject specFlowProject, string basePath) { List<BindingInfo> bindings = new List<BindingInfo>(); var reportingFolder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); AppDomainSetup appDomainSetup = new AppDomainSetup(); appDomainSetup.ApplicationBase = reportingFolder; AppDomain appDomain = AppDomain.CreateDomain("CollectBindings", null, appDomainSetup); AssemblyServices.SubscribeAssemblyResolve(appDomain, basePath); BindingCollector bindingCollector = (BindingCollector)appDomain.CreateInstanceAndUnwrap( Assembly.GetExecutingAssembly().GetName().FullName, typeof(BindingCollector).FullName); bindings.AddRange(bindingCollector.CollectBindings(specFlowProject.AssemblyName)); AppDomain.Unload(appDomain); return bindings; }
public SpecFlowGenerator(SpecFlowProject project) { this.project = project; }
public static GherkinFileEditorParser GetParser(ITextBuffer buffer, IClassificationTypeRegistryService classificationRegistry, SpecFlowProject specFlowProject) { return buffer.Properties.GetOrCreateSingletonProperty(() => new GherkinFileEditorParser(buffer, classificationRegistry, specFlowProject)); }
public string GetFullPath(SpecFlowProject project) { return Path.GetFullPath(Path.Combine(project.ProjectFolder, ProjectRelativePath)); }
public static List<Feature> GetParsedFeatures(SpecFlowProject specFlowProject) { return GetParsedFeatures(specFlowProject.FeatureFiles.Select(ff => ff.GetFullPath(specFlowProject)), specFlowProject.GeneratorConfiguration.FeatureLanguage); }
public NUnitExecutionReportGenerator(NUnitExecutionReportParameters reportParameters) { specFlowProject = MsBuildProjectReader.LoadSpecFlowProjectFromMsBuild(reportParameters.ProjectFile); this.reportParameters = reportParameters; }
public NUnitExecutionReportGenerator(string projectFile, string xmlTestResultPath, string labeledTestOutputPath) { this.xmlTestResultPath = xmlTestResultPath; this.specFlowProject = MsBuildProjectReader.LoadSpecFlowProjectFromMsBuild(projectFile); this.labeledTestOutputPath = labeledTestOutputPath; }
public NUnitExecutionReportGenerator(SpecFlowProject specFlowProject, string xmlTestResultPath, string labeledTestOutputPath) { this.xmlTestResultPath = xmlTestResultPath; this.specFlowProject = specFlowProject; this.labeledTestOutputPath = labeledTestOutputPath; }
public string GetFullPath(SpecFlowProject project) { return(Path.GetFullPath(Path.Combine(project.ProjectFolder, ProjectRelativePath))); }