问题
Currently working on a series of projects that are contained within one solution in VS2017. Each project is a specflow project, within one solution. I would like to setup the Hooks.cs file such that it's valid for any test within the entire solution, not just the project. I'd also like to make step definitions from one project available to the other projects as a base or utility step definition.
How would I go about structuring specflow to make this possible?
回答1:
You can use steps and hooks from different assemblies.
You can add in the configuration a list of additional step assemblies like this:
<specFlow>
<stepAssemblies>
<stepAssembly assembly="MySharedBindings" />
</stepAssemblies>
</specFlow>
The documentation is here: https://specflow.org/documentation/Use-Bindings-from-External-Assemblies/
But there are some known problems with it:
- IntelliSense and Syntax Highlighting has some problems (https://github.com/techtalk/SpecFlow/issues/838)
- Hooks could be registered double (https://github.com/techtalk/SpecFlow/issues/1004)
来源:https://stackoverflow.com/questions/53820422/specflow-setup-to-share-hooks-and-step-definitions-across-vs-projects