【问题标题】:Specflow plugin : Generation error: Missing [assembly:GeneratorPlugin] attribute inSpecflow 插件:生成错误:缺少 [assembly:GeneratorPlugin] 属性
【发布时间】:2013-09-12 07:52:23
【问题描述】:

我正在编写一个自定义插件来自定义 SpecFlow 生成的自动生成的代码文件。

在构建解决方案并将其放入 SpecFlow 测试项目的“lib”文件夹后。在保存 SpecFlow 功能文件时,我得到了

Specflow plugin : Generation error: Missing [assembly:GeneratorPlugin] attribute in 'path to dll'

即使我在插件程序集中标记了这个

[assembly: GeneratorPluginAttribute(typeof(CustomGeneratorPlugin))]

使用反射/自测试我可以自己加载程序集并解析属性

代码在这里 -- https://github.com/chrismckelt/SpecFlowCustomPlugin

任何想法是什么导致了这个?谢谢

【问题讨论】:

  • 程序集版本控制可能吗?您确定属性的 Type 引用的程序集与 SpecFlow 的插件主机在运行时定义的程序集完全相同吗?
  • 如果你真的被卡住了,你可以从github.com/techtalk/SpecFlow编译你自己的specflow副本,并在它记录错误之前添加一个Debugger.Launch()?或者只是使用 devenv 来调试您正在加载插件的 devenv?
  • 嗨,是的,Debugger.Launch 做了 - 但是它通过 VS 扩展运行时几乎没有问题 - 更改 VS SpecFlow dll 会导致各种问题(它们是否已签名?)并且必须在 VS 中卸载/重新安装
  • 也考虑了版本。使用 VS SpecFlow Extensions 1.9.2.1 中的相同版本重新编译,但没有运气。如果有人知道这是否可行,是否愿意再次尝试通过 Visual Studio Extensions 进行调试?
  • 您可能想尝试联系 Gaspar Nagy 以获取有关使其在调试下运行的建议 (stackoverflow.com/users/26530/gaspar-nagy)

标签: c# .net-assembly specflow xunit


【解决方案1】:

通过将以下“路径”属性添加到生成器 SpecFlow 配置部分来解决

<generator path=".\lib" 

完整配置

<specFlow>
    <generator allowDebugGeneratedFiles="false" allowRowTests="true" generateAsyncTests="false" path=".\lib" />
    <runtime stopAtFirstError="false" missingOrPendingStepsOutcome="Ignore" />
    <trace traceSuccessfulSteps="true" traceTimings="false" minTracedDuration="0:0:0.1" stepDefinitionSkeletonStyle="RegexAttribute" />
    <plugins>
        <add name="McKeltCustom" path=".\lib" type="GeneratorAndRuntime" />
    </plugins>
    <stepAssemblies>
        <stepAssembly assembly="SpecFlow.Assist.Dynamic" />
    </stepAssemblies>
</specFlow>

【讨论】:

    【解决方案2】:

    我通过在我的 SpecflowPlugin 项目中将所有引用的 TechTalk.SpecFlow dll 的本地复制标志设置为 false 来解决此问题。

    【讨论】:

      猜你喜欢
      • 2017-02-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-09-12
      • 2011-02-16
      • 2011-02-15
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多