コード例 #1
0
ファイル: BatchGenerator.cs プロジェクト: mastoj/SpecFlow
        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);
                    }
                }
            }
        }
コード例 #2
0
        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);
            }
        }
コード例 #3
0
ファイル: BatchGenerator.cs プロジェクト: nnanoob/SpecFlow-1
        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);
        }
コード例 #4
0
        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}");
                }
            }
        }
コード例 #5
0
        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);
        }
コード例 #6
0
        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();
            }
        }
コード例 #7
0
 private void ForwardMessage(TraceMessage message)
 {
     if (message.IsToolMessage)
     {
         traceListener.WriteToolOutput(message.Message);
     }
     else
     {
         traceListener.WriteTestOutput(message.Message);
     }
 }
コード例 #8
0
        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);
        }
コード例 #9
0
        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);
        }
コード例 #10
0
 public void WriteLine(string message)
 {
     _testThreadExecutionEventPublisher.PublishEvent(new OutputAddedEvent(message));
     _traceListener.WriteToolOutput(message);
 }
コード例 #11
0
 public void TraceWarning(string text)
 {
     traceListener.WriteToolOutput("warning: {0}", text);
 }
コード例 #12
0
 public void TraceConfigSource(ITraceListener traceListener, SpecFlowConfiguration specFlowConfiguration)
 {
     traceListener.WriteToolOutput($"Using config from: {_configFilePath ?? "<default>"}");
 }
コード例 #13
0
ファイル: ITraceListener.cs プロジェクト: nnanoob/SpecFlow-1
 public static void WriteToolOutput(this ITraceListener traceListener, string messageFormat, params object[] args)
 {
     traceListener.WriteToolOutput(string.Format(messageFormat, args));
 }
コード例 #14
0
 public virtual void AddAttachment(string filePath)
 {
     _traceListener.WriteToolOutput($"Attachment '{filePath}' added (not forwarded to the test runner).");
 }