SpecFlowPlugin 中缺少 [assembly:RuntimePlugin] 属性

Missing [assembly:RuntimePlugin] attribute in SpecFlowPlugin

我在他们下面的页面之后创建了一个 SpecFlow 插件。并创建了一个生成器插件,因为我需要修改我的功能背后的自动生成代码。

https://github.com/techtalk/SpecFlow/wiki/Plugins

SpecFlowPlugin 代码

[assembly: GeneratorPlugin(typeof(SpecFlowSpiraAdapterPlugin))]
namespace SpiraTest.SpecFlowPlugin
{
    /// <summary>
    /// A adapterpPlugin is needed to use a custom MSTest generator with SpecFlow.
    /// </summary>
    public class SpecFlowSpiraAdapterPlugin : IGeneratorPlugin
    {
        /// <summary>
        /// By implementing the Initialize- Method on the IGeneratorPlugin interface, you get access to the GeneratorPluginEvents and GeneratorPluginParameters
        /// </summary>
        /// <param name="generatorPluginEvents"></param>
        /// <param name="generatorPluginParameters"></param>
        public void Initialize(GeneratorPluginEvents generatorPluginEvents, GeneratorPluginParameters generatorPluginParameters)
        {
            generatorPluginEvents.CustomizeDependencies += GeneratorPluginEvents_CustomizeDependencies;
        }       

        private void GeneratorPluginEvents_CustomizeDependencies(object sender, CustomizeDependenciesEventArgs e)
        {
            e.ObjectContainer.RegisterTypeAs<MSTestCustomGenerator, IUnitTestGeneratorProvider>();
        }
    }
}

问题

我在尝试 运行 我的测试时收到一条错误消息,表明我没有以下属性。

[assembly:RuntimePlugin] attribute

但是我不需要那个属性,因为我有 [assembly: GeneratorPlugin] 属性。

不知道为什么这么说。有什么想法吗?


Message: Class Initialization method MiJobsAdminPortal.UITests.Login.LoginFeature.FeatureSetup threw exception. TechTalk.SpecFlow.SpecFlowException: TechTalk.SpecFlow.SpecFlowException: Missing [assembly:RuntimePlugin] attribute in SpiraTest.SpecFlowPlugin, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null. Please check http://go.specflow.org/doc-plugins for details..

对于 SpecFlow,每个插件都是一个生成器和一个运行时插件,除非您以其他方式配置它。这是对应的代码:https://github.com/techtalk/SpecFlow/blob/master/TechTalk.SpecFlow/Infrastructure/ContainerBuilder.cs#L127

作为配置的例子,看一下SpecFlow+Excel插件的配置,它也只是一个生成器插件。

<specFlow>
    <plugins>
      <add name="SpecFlow.Plus.Excel" type="Generator" />
    </plugins>
</specFlow>

您必须将类型指定为 Generator。如果不是,SpecFlow 总是搜索这两种插件类型。

这种行为没有记录在案,但多年来一直存在。我会在接下来的几天更新文档。


完全披露:我是 SpecFlow 和 SpecFlow+ 的维护者之一