public void ProcessProject(SpecFlowProject specFlowProject, bool forceGenerate) { traceListener.WriteToolOutput("Processing project: " + specFlowProject.ProjectSettings.ProjectName); GenerationSettings generationSettings = GetGenerationSettings(forceGenerate); using (var generator = CreateGenerator(specFlowProject)) { foreach (var featureFile in specFlowProject.FeatureFiles) { var featureFileInput = CreateFeatureFileInput(featureFile, generator, specFlowProject); var generationResult = GenerateTestFile(generator, featureFileInput, generationSettings); if (!generationResult.Success) { traceListener.WriteToolOutput("{0} -> test generation failed", featureFile.ProjectRelativePath); } else if (generationResult.IsUpToDate) { traceListener.WriteToolOutput("{0} -> test up-to-date", featureFile.ProjectRelativePath); } else { traceListener.WriteToolOutput("{0} -> test updated", featureFile.ProjectRelativePath); } } } }
private void LogTestSessionDetails(string sessionId) { var session = _browserStackService.GetSessionDetail(sessionId); _traceListener.WriteTestOutput("---------------------------------------------------------------------------"); _traceListener.WriteToolOutput("browser stack session detail: " + session.BrowserUrl); if (!string.IsNullOrWhiteSpace(session.VideoUrl)) { _traceListener.WriteToolOutput("video url: " + session.VideoUrl); } }
public bool ProcessProject(SpecFlowProject specFlowProject, bool forceGenerate) { traceListener.WriteToolOutput("Processing project: " + specFlowProject.ProjectSettings.ProjectName); GenerationSettings generationSettings = GetGenerationSettings(forceGenerate); bool success = true; using (var generator = CreateGenerator(specFlowProject)) { traceListener.WriteToolOutput("Using Generator: {0}", generator.GetType().FullName); foreach (var featureFile in specFlowProject.FeatureFiles) { var featureFileInput = CreateFeatureFileInput(featureFile, generator, specFlowProject); var generationResult = GenerateTestFile(generator, featureFileInput, generationSettings); if (!generationResult.Success) { traceListener.WriteToolOutput("{0} -> test generation failed", featureFile.ProjectRelativePath); success = false; if (OnError != null) { OnError(featureFile, generationResult); } } else if (generationResult.IsUpToDate) { traceListener.WriteToolOutput("{0} -> test up-to-date", featureFile.ProjectRelativePath); } else { traceListener.WriteToolOutput("{0} -> test updated", featureFile.ProjectRelativePath); if (OnGenerated != null) { OnGenerated(featureFile, generationResult); } } if (generationResult.Success) { if (OnSuccess != null) { OnSuccess(featureFile, generationResult); } } } } return(success); }
public void AfterScenario() { foreach (var key in context.Keys) { var instance = provider.Create(key); Assert.AreEqual(context.Id.ToString(), instance.Resolver.GetScenarioId()); tracer.WriteToolOutput($"context of {instance.Id}:"); tracer.WriteToolOutput($"[scenarioId]={instance.Resolver.GetScenarioId()}"); foreach (var item in instance.Context.Collection) { tracer.WriteToolOutput($"[{item.Key}]={item.Value}"); } } }
protected virtual void LoadPlugin(string pluginPath, IRuntimePluginLoader pluginLoader, RuntimePluginEvents runtimePluginEvents, UnitTestProviderConfiguration unitTestProviderConfigration, ITraceListener traceListener) { traceListener.WriteToolOutput($"Loading plugin {pluginPath}"); var plugin = pluginLoader.LoadPlugin(pluginPath, traceListener); var runtimePluginParameters = new RuntimePluginParameters(); plugin?.Initialize(runtimePluginEvents, runtimePluginParameters, unitTestProviderConfigration); }
public void TraceConfigSource(ITraceListener traceListener, SpecFlowConfiguration specFlowConfiguration) { switch (specFlowConfiguration.ConfigSource) { case ConfigSource.Default: traceListener.WriteToolOutput("Using default config"); break; case ConfigSource.AppConfig: traceListener.WriteToolOutput("Using app.config"); break; case ConfigSource.Json: traceListener.WriteToolOutput("Using specflow.json"); break; default: throw new ArgumentOutOfRangeException(); } }
private void ForwardMessage(TraceMessage message) { if (message.IsToolMessage) { traceListener.WriteToolOutput(message.Message); } else { traceListener.WriteTestOutput(message.Message); } }
public IRuntimePlugin LoadPlugin(string pluginAssemblyName, ITraceListener traceListener, bool traceMissingPluginAttribute) { Assembly assembly; try { #if NETSTANDARD assembly = PluginAssemblyResolver.Load(pluginAssemblyName); #else assembly = Assembly.LoadFrom(pluginAssemblyName); #endif } catch (Exception ex) { throw new SpecFlowException(string.Format("Unable to load plugin: {0}. Please check https://go.specflow.org/doc-plugins for details.", pluginAssemblyName), ex); } var pluginAttribute = (RuntimePluginAttribute)Attribute.GetCustomAttribute(assembly, typeof(RuntimePluginAttribute)); if (pluginAttribute == null) { if (traceMissingPluginAttribute) { traceListener.WriteToolOutput(string.Format("Missing [assembly:RuntimePlugin] attribute in {0}. Please check https://go.specflow.org/doc-plugins for details.", assembly.FullName)); } return(null); } if (!typeof(IRuntimePlugin).IsAssignableFrom(pluginAttribute.PluginType)) { throw new SpecFlowException(string.Format("Invalid plugin attribute in {0}. Plugin type must implement IRuntimePlugin. Please check https://go.specflow.org/doc-plugins for details.", assembly.FullName)); } IRuntimePlugin plugin; try { plugin = (IRuntimePlugin)Activator.CreateInstance(pluginAttribute.PluginType); } catch (Exception ex) { throw new SpecFlowException(string.Format("Invalid plugin in {0}. Plugin must have a default constructor that does not throw exception. Please check https://go.specflow.org/doc-plugins for details.", assembly.FullName), ex); } return(plugin); }
public IRuntimePlugin LoadPlugin(string pluginAssemblyName, ITraceListener traceListener) { //var assemblyName = string.Format(ASSEMBLY_NAME_PATTERN, pluginDescriptor.Name); Assembly assembly; try { assembly = LoadAssembly(pluginAssemblyName); } catch (Exception ex) { throw new SpecFlowException(string.Format("Unable to load plugin: {0}. Please check http://go.specflow.org/doc-plugins for details.", pluginAssemblyName), ex); } var pluginAttribute = (RuntimePluginAttribute)Attribute.GetCustomAttribute(assembly, typeof(RuntimePluginAttribute)); if (pluginAttribute == null) { traceListener.WriteToolOutput(string.Format("Missing [assembly:RuntimePlugin] attribute in {0}. Please check http://go.specflow.org/doc-plugins for details.", assembly.FullName)); return(null); } if (!typeof(IRuntimePlugin).IsAssignableFrom((pluginAttribute.PluginType))) { throw new SpecFlowException(string.Format("Invalid plugin attribute in {0}. Plugin type must implement IRuntimePlugin. Please check http://go.specflow.org/doc-plugins for details.", assembly.FullName)); } IRuntimePlugin plugin; try { plugin = (IRuntimePlugin)Activator.CreateInstance(pluginAttribute.PluginType); } catch (Exception ex) { throw new SpecFlowException(string.Format("Invalid plugin in {0}. Plugin must have a default constructor that does not throw exception. Please check http://go.specflow.org/doc-plugins for details.", assembly.FullName), ex); } return(plugin); }
public void WriteLine(string message) { _testThreadExecutionEventPublisher.PublishEvent(new OutputAddedEvent(message)); _traceListener.WriteToolOutput(message); }
public void TraceWarning(string text) { traceListener.WriteToolOutput("warning: {0}", text); }
public void TraceConfigSource(ITraceListener traceListener, SpecFlowConfiguration specFlowConfiguration) { traceListener.WriteToolOutput($"Using config from: {_configFilePath ?? "<default>"}"); }
public static void WriteToolOutput(this ITraceListener traceListener, string messageFormat, params object[] args) { traceListener.WriteToolOutput(string.Format(messageFormat, args)); }
public virtual void AddAttachment(string filePath) { _traceListener.WriteToolOutput($"Attachment '{filePath}' added (not forwarded to the test runner)."); }