SpecFlow.xUnitAdapter is an xUnit adapter for SpecFlow that allows running scenarios without code generation.
Currently supports
- SpecFlow v2.1
- xUnit v2.2 or above
License: Apache (https://github.com/gasparnagy/SpecFlow.xUnitAdapter/blob/master/LICENSE)
NuGet: https://www.nuget.org/packages/SpecFlow.xUnitAdapter
See my blog post (http://gasparnagy.com/2017/04/specflow-without-code-behind-files/) for more information and background, you can also look at the complete example at https://github.com/gasparnagy/SpecFlow.xUnitAdapter/tree/master/sample/MyCalculator or watch the video demo on YouTube.
If you like this plugin and would like to support developing this or similar plugins, please consider donating the project. (For receiving an invoice for your donation, please contact me upfront.)
PM> Install-Package SpecFlow.xUnitAdapter
To disable the code-behind code generation, you have to REMOVE (set it to empty) the "SpecFlowSingleFileGenerator" "Custom Tool" setting on the file properties of all feature files in Visual Studio.
If you do this, Visual Studio will automatically delete the code behind files and removes them from the project.
The SpecFlow.xUnitAdapter currently processes feature files in the folder (or subfolders) of the SpecFlow project assembly (typically in bin\Debug).
To achieve that, you should change the "Copy to Output Directory" setting of the feature files to "Copy if newer".
In order to run the tests from the Visual Studio Test Explorer Window, you can install the xUnit Visual Studio adapter.
PM> Install-Package xunit.runner.visualstudio
The adapter is currently in BETA and there are some limitations.
- The feature files are executed from the output directory, so if you open a scenario by clicking on the test in the Visual Studio Test Explorer window, the "copy" will be opened, so any changes there will be lost at the next compilation.
- As Visual Studio Test Explorer window only triggers the re-discovery of tests when the output assembly changes, if you only change the feature files, but nothing else in the code, you need to Rebuild the project in order to see the changes. (This is important only if the change is related to the discovered tests, so for example if you change the scenario name or the examples section of a scenario outline.)
- The adapter currently does not load the project-level feature file language setting (but assumes
en-US
). - For feature files with
#language
setting, the setting will only be used for data conversions if it is a specific culture (e.g.de-AT
). For neutral languages (e.g.de
), currentlyen-US
is used for conversions. - The adapter adds all tests into a single test collection, so they cannot be run parallel.