Specflow CodedUI 生成器插件不生成功能文件

Specflow CodedUI Generator Plugin not generating feature files

好的。所以这就是我所在的位置。我正在使用 Specflow 2.2.0 将自动化单元测试与我们的 CodedUI 测试工作配对。我正在开发一个插件来将 CodedUI 测试属性添加到 Specflow 功能测试中,我 运行 遇到了一些问题。 Specflow 无法识别我的插件来为 Specflow 功能文件生成 CodedUI 测试属性,我不明白为什么,因为我已经按照文档中的每条说明进行操作,并查看了 GitHub 上的其他插件以确保我是做对了。

我在它自己的 class 库项目中有这个插件,并且在构建它的 dll 时自动复制到 Specflow 所在的解决方案中的 packages 文件夹。我编辑了程序集文件以指向生成器。我有事件处理程序的初始值设定项。据我所知,我的 CodedUI 项目的 app.config 中的所有内容都是正确的,但我仍然遇到错误。这是我对插件和其他相关部分的所有了解:

这是我的插件中用于初始化 IGenerator 的代码 Class:

namespace SpecflowCUITPluginLib
{
    public class CodedUiPlugin : IGeneratorPlugin
    {
        public void Initialize(GeneratorPluginEvents generatorPluginEvents, GeneratorPluginParameters generatorPluginParameters)
        {
            generatorPluginEvents.CustomizeDependencies += this.GeneratorPluginEventsOnCustomizeDependencies;
        }
        private void GeneratorPluginEventsOnCustomizeDependencies(object sender, CustomizeDependenciesEventArgs customizeDependenciesEventArgs)
        {
            string unitTestProviderName =
              customizeDependenciesEventArgs.SpecFlowProjectConfiguration.SpecFlowConfiguration.UnitTestProvider;
            if (unitTestProviderName.Equals("mstest", StringComparison.InvariantCultureIgnoreCase)
              || unitTestProviderName.Equals("mstest.2010", StringComparison.InvariantCultureIgnoreCase))
            {
                customizeDependenciesEventArgs.ObjectContainer.RegisterTypeAs<CodedUIGeneratorProvider, IUnitTestGeneratorProvider>();
            }
        }
        #region IGeneratorPlugin Members
        public void RegisterConfigurationDefaults(TechTalk.SpecFlow.Generator.Configuration.SpecFlowProjectConfiguration specFlowConfiguration) { }
        public void RegisterCustomizations(BoDi.ObjectContainer container, TechTalk.SpecFlow.Generator.Configuration.SpecFlowProjectConfiguration generatorConfiguration)
        {
            container.RegisterTypeAs<CodedUIGeneratorProvider, IUnitTestGeneratorProvider>();
            container.RegisterTypeAs<MsTest2010RuntimeProvider, IUnitTestRuntimeProvider>();
        }
        public void RegisterDependencies(BoDi.ObjectContainer container) { }
        #endregion
    }
}

这是来自我的 Generator Provider 的代码,它位于一个单独的 .cs 文件中:

namespace SpecflowCUITPluginLib
{

    public class CodedUIGeneratorProvider : MsTest2010GeneratorProvider
    {
        public CodedUIGeneratorProvider(CodeDomHelper codeDomHelper)
            : base(codeDomHelper) { }
        private const string TestClassAttribute = @"Microsoft.VisualStudio.TestTools.UnitTesting.TestClassAttribute";
        private const string CodedUiTestClassAttribute = @"Microsoft.VisualStudio.TestTools.UITesting.CodedUITestAttribute";
        private const string DeploymentItemAttribute = "Microsoft.VisualStudio.TestTools.UnitTesting.DeploymentItemAttribute";
        public override void SetTestClass(TestClassGenerationContext generationContext, string featureTitle, string featureDescription)
        {
            base.SetTestClass(generationContext, featureTitle, featureDescription);
            foreach (CodeAttributeDeclaration declaration in generationContext.TestClass.CustomAttributes)
            {
                if (declaration.Name == TestClassAttribute)
                {
                    generationContext.TestClass.CustomAttributes.Remove(declaration);
                    break;
                }
            }
            generationContext.TestClass.CustomAttributes.Add(new CodeAttributeDeclaration(new CodeTypeReference(CodedUiTestClassAttribute)));
            string filename = new Uri(this.GetType().Assembly.CodeBase).LocalPath;
            // Add deployment item in each test for the driver.
            generationContext.TestClass.CustomAttributes.Add(
                new CodeAttributeDeclaration(
                    new CodeTypeReference(DeploymentItemAttribute),
                    new CodeAttributeArgument(new CodePrimitiveExpression("SpecflowCUITPluginLib.SpecFlowPlugin.dll"))));
        }
    }
}

这是我添加到程序集文件中的行:

[assembly: GeneratorPlugin(typeof(CodedUiPlugin))]

Here is a screencap of my build settings for the plugin project

这是我的 app.config 来自我的 CodedUI 项目

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <section name="specFlow" type="TechTalk.SpecFlow.Configuration.ConfigurationSectionHandler, TechTalk.SpecFlow" />
  </configSections>
  <specFlow>
    <unitTestProvider name="MsTest" />
    <plugins>
      <add name="SpecflowCUITPluginLib.SpecflowPlugin" path=".\MedchartUITesting\packages\specflow2.2.0\tools" type="Generator" />
    </plugins>
  </specFlow>
</configuration>

无论我做什么,我的功能文件都会出现此错误:#error Generation error: Unable to find plugin in the plugin search path: SpecflowCUITPluginLib.SpecflowPlugin. Please check http://go.specflow.org/doc-plugins for details.

任何人都看到了解决方案或问题,因为此刻我真的不知道应该在哪里寻找解决方案。

问题是插件所在路径配置错误。
请参阅 SpecFlow 论坛中的主题:https://groups.google.com/forum/#!topic/specflow/ZcbuoJLfJ_E