[英]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.