简体   繁体   English

当使用不同装配中的步骤定义时,转到定义(F12)不起作用

[英]Go To Definition (F12) not working when step definitions are used from a different assembly

Go To Definition (F12) is not working when step definitions are used from a different assembly. 当使用不同装配中的步骤定义时,转到定义(F12)不起作用。 Is there a way to make it work? 有办法使它起作用吗?

This could be a bug or something like that in Specflow. 这可能是Bug或类似Specflow中的问题。 I have the exact same problem. 我有完全一样的问题。 When trying to go to the Step Definition from the feature file, Visual Studio says there's no matching step binding. 尝试从功能文件转到“步骤定义”时,Visual Studio表示没有匹配的步骤绑定。 Although, when trying to run the test(s), they run like they should, so Specflow can indeed find (and use) the matching step definitions. 虽然,当尝试运行测试时,它们的运行与预期的一样,因此Specflow确实可以找到(并使用)匹配的步骤定义。

Bindings in external assemblies are not fully supported in the SpecFlow 1.8 Visual Studio Extension. SpecFlow 1.8 Visual Studio扩展不完全支持外部程序集中的绑定。 It is stated in their documentation here . 这是他们的文档中所述这里 SpecFlow supports them, but the Visual Studio Extension does so only partially. SpecFlow支持它们,但是Visual Studio Extension仅部分支持。 I am unsure whether 1.9 resolves this issue or not. 我不确定1.9是否可以解决此问题。

I know i am a little late for dinner, but seems like SpecFlow stores all it's binding data in the user's %temp% folder, and those files are simple .json files that map between feature files and steps files. 我知道我晚饭要晚了一点,但是似乎SpecFlow将所有绑定数据存储在用户的%temp%文件夹中,这些文件是简单的.json文件,它们映射在功能文件和步骤文件之间。

So, when the steps are in the same solution as your .feature files - SpecFlow is able to detect the correct source file and the exact location of the step method. 因此,当步骤与您的.feature文件位于同一解决方案中时-SpecFlow能够检测正确的源文件和step方法的确切位置。

But, when the steps are in a referenced dll, the .json config files are not enough to locate the metadata in the dll, hence F12 is not working. 但是,当步骤位于引用的dll中时,.json配置文件不足以在dll中定位元数据,因此F12无法正常工作。

I am guessing this would require some sort of design-time reflection on the referenced assemblies to make F12 work. 我猜想这将需要对引用的程序集进行某种设计时反射,以使F12正常工作。

It might be obvious, but make sure you install the SpecFlow extension. 这可能很明显,但是请确保安装SpecFlow扩展。

Tools -> Extensions/Updates -> Online -> Search for "Specflow" 工具->扩展/更新->在线->搜索“ Specflow”

@ShonnLyga thanks a lot that was really useful @ShonnLyga非常感谢,这真的很有用

To reference the assemblies from a DLL you can now use 要从DLL引用程序集,您现在可以使用

<specFlow>
    <unitTestProvider name="NUnit" />
    <stepAssemblies>
      <stepAssembly assembly="YourDLLname" />
    </stepAssemblies>
</specFlow>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 VSCode C#“转到定义”(F12)不起作用 - VSCode C# "go to definition" (F12) not working 当按F12进入Visual Studio 2015 / C#中的定义时出现错误 - I got error when press F12 Go to definition in Visual Studio 2015 / C# 如何隐藏<summary>在 Visual Studio 代码中按 F12(转到定义)时的 [元数据]</summary> - How to hide <summary> in [metadata] when press F12 (Go to definition) in visual studio code Visual Studio转到定义(F12)打开对象浏览器而不是代码视图 - Visual Studio Go to Definition (F12) opens Object Browser instead of Code View VS2010 C#:如何在按F12键时查看内部​​类的定义? - VS2010 C#: How to view internal classes definitions when I press F12? (函数,全局变量)之间的Visual Studio 2019脚本标记(在cshtml中)转到定义(F12)不起作用 - Visual Studio 2019 script tags (in cshtml) between (function,global variable) go to definition (F12) doesn't work 如何按键执行字符串(F12)? - How to execute a string by key (F12)? 如何防止任何人在按F12键时看到方法语句代码? - How to prevent anyone sees method statements code when pressing F12? 如果我只有 DLL 和 PDB 文件,有没有办法在按 F12 时浏览源代码? - Is there a way to browser Source Code when pressing F12 if I only have the DLL and PDB files? 开发人员工具(F12)Internet Explorer清空控制台,但不支持Firefox - Developer tools (F12) internet explorer empty console but not with firefox
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM