Skip to content

SpecFlow Assembly References

Gáspár Nagy edited this page Jul 3, 2019 · 3 revisions

Support for SpecFlow assembly references (non-NuGet)

Normally Deveroom can detect all SpecFlow project setting based on the installed NuGet packages.

When the SpecFlow package is configured with direct assembly references, you might need to specify further settings in the Deveroom configuration file (deveroom.json). This pages describes the necessary settings.

These settings can be ignored when you use the SpecFlow NuGet packages!

When your project uses design-time feature file code-behind generation

Using the design-time feature file code-behind generation was the default option for SpecFlow v2 and earlier. With this option, every time you save a feature file, the code-behind file (MyFeature.feature.cs) is regenerated. The generation is specified using the SpecFlowSingleFileGenerator setting for the Custom Tool property for the individual feature files.

To configure design-time feature file code-behind generation for projects that do not use NuGet SpecFlow references, you need to

  • Add a deveroom.json configuration file to the project root. (You can add it using the "Add / New item..." dialog, see Configuration for details.)
  • Add a specFlow section to the file.
  • Set specFlow/isSpecFlowProject to true
  • Set specFlow/generatorFolder to the folder where the SpecFlow generator (TechTalk.SpecFlow.Generator.dll) is located. This is usually the tools folder of the SpecFlow NuGet package.

Example

{
  "$schema": "http://schemas.specsolutions.eu/deveroom-config-latest-alpha.json",

  "specFlow": {
    "isSpecFlowProject": true,
    "generatorFolder": "..\\MyDependencies\\SpecFlow.2.3.0\\tools"
  }
}

When your project uses build-time feature file code-behind generation

If your project is configured to regenerate feature files during build-time, but not with the SpecFlow.Tools.MsBuild.Generation NuGet package (e.g. with a custom MsBuild extension or by calling specflow.exe from a build event), the basic SpecFlow settings can be detected automatically by Deveroom.

Overriding automatically detected SpecFlow settings

Any automatically detected SpecFlow setting can be overridden using the specFlow section of the Deveroom configuration file (deveroom.json).

  • specFlow/isSpecFlowProject -- whether the project should be considered as a SpecFlow project by Deveroom
  • specFlow/generatorFolder -- The path of the SpecFlow generator folder used by the project, that is usually the tools folder of the SpecFlow NuGet package, e.g. ..\\MyDependencies\\SpecFlow.2.3.0\\tools.
  • specFlow/configFilePath -- The path of the SpecFlow configuration file (App.config or specflow.json) used by the project, e.g. specflow.json.
  • specFlow/version -- The SpecFlow version used by the project, e.g. 2.3.1
  • traits -- The list of the SpecFlow-related project traits. The possible traits are: MsBuildGeneration, XUnitAdapter, DesignTimeFeatureFileGeneration, e.g. ["XUnitAdapter"]

Note: In order to process the other SpecFlow-related settings, the specFlow/isSpecFlowProject setting must be set to true.

Example

{
  "$schema": "http://schemas.specsolutions.eu/deveroom-config-latest-alpha.json",

  "specFlow": {
    "isSpecFlowProject": true,
    "generatorFolder": "..\\MyDependencies\\SpecFlow.2.3.0\\tools",
    "configFilePath": "specflow.json",
    "version": "2.3.1",
    "traits": ["DesignTimeFeatureFileGeneration"]
  }
}