简体   繁体   中英

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. Is there a way to make it work?

This could be a bug or something like that in 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. Although, when trying to run the test(s), they run like they should, so Specflow can indeed find (and use) the matching step definitions.

Bindings in external assemblies are not fully supported in the SpecFlow 1.8 Visual Studio Extension. It is stated in their documentation here . SpecFlow supports them, but the Visual Studio Extension does so only partially. I am unsure whether 1.9 resolves this issue or not.

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.

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.

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.

I am guessing this would require some sort of design-time reflection on the referenced assemblies to make F12 work.

It might be obvious, but make sure you install the SpecFlow extension.

Tools -> Extensions/Updates -> Online -> Search for "Specflow"

@ShonnLyga thanks a lot that was really useful

To reference the assemblies from a DLL you can now use

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM