-
Notifications
You must be signed in to change notification settings - Fork 0
Configuration
The behavior of SpecFlow can be extensively configured through .NET configuration files. SpecFlow processes the configuration file of the acceptance test projects (the projects that contain the feature files). The configuration has to be placed in a file called “App.config” (the standard configuration file convention for .NET).
Unlike other runtime-only tools, SpecFlow processes the configuration file also while it generates the unit-tests from the feature files (this happens usually when you save the feature file). This means that after you have changed the configuration file, you might need to force re-generation of the unit test (if the configuration change affects the generated tests). The Visual Studio 2010 Integration can detect the change of the configuration file and offers re-generation.
In SpecFlow all configuration option has a default setting, so in an extreme case you don’t need to specify any configuration file. Commonly the most important thing to configure is the unit test provider. Therefore simple SpecFlow projects configure only this aspect. The following example shows such a simple configuration.
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="specFlow"
type="TechTalk.SpecFlow.Configuration.ConfigurationSectionHandler, TechTalk.SpecFlow"/>
</configSections>
<specFlow>
<unitTestProvider name="MsTest" />
</specFlow>
</configuration>
The following example shows all possible configuration option with their default values (the config section definition has been omitted for better readability).
<specFlow>
<language feature="en-US" tool="{not-specified}" />
<bindingCulture name="{not-specified}" />
<unitTestProvider name="NUnit" />
<generator
allowDebugGeneratedFiles="false"
allowRowTests="true" />
<runtime
detectAmbiguousMatches="true"
stopAtFirstError="false"
missingOrPendingStepsOutcome="Inconclusive" />
<trace
traceSuccessfulSteps="true"
traceTimings="false"
minTracedDuration="0:0:0.1"
listener="TechTalk.SpecFlow.Tracing.DefaultListener, TechTalk.SpecFlow" />
<stepAssemblies>
<!-- <stepAssembly assembly="{name-of-assembly-containing-bindgins}" /> -->
</stepAssemblies>
</specFlow>
This section can be used to define the default language for the feature files and other language-related settings. Read more about the language settings in the Feature Language page.
Attribute | Value | Description |
---|---|---|
feature | culture name (“en-US”) | The default language of the feature files added to the project.
It is recommended to use specific culture names (e.g.: “en-
US”) and not generic (neutral) cultures (e.g.: “en”). Default: en-US |
tool | empty or culture name | Specifies the language that SpecFlow uses for messages and
tracing. Uses the default feature language if empty if supported otherwise
the messages are displayed in English. (Currently only English is supported.) Default: empty |
Attribute | Value | Description |
---|---|---|
name | culture name (“en-US”) | Specifies a culture to be used to execute binding methods and convert step arguments. If not specified, the feature language is used. Default: not specified |
This section can be used to specify the unit-test framework SpecFlow uses to execute the acceptance criteria. You can either use one of the built-in unit-test providers or you can specify the classes that implement the custom unit test providers.
Attribute | Value | Description |
---|---|---|
name | Name of the unit test provider. See Unit Test Providers. | The name of the built-in unit test provider. If you specify this attribute,
you don’t have to specify the other two. Default: NUnit |
generatorProvider | class name | An assembly qualified class name of a class that implements
TechTalk.SpecFlow.Generator.UnitTestProvider.IUnitTestGeneratorProvider
interface. |
runtimeProvider | class name | An assembly qualified class name of a class that implements
TechTalk.SpecFlow.UnitTestProvider.IUnitTestRuntimeProvider
interface. |
This section can be used to specify various unit-test generation options.
Attribute | Value | Description |
---|---|---|
allowDebugGeneratedFiles | true/false | The debugger is by default configured to step through the generated code. This helps to debug from the feature files directly to the bindings (see Debugging Tests). This feature can be disabled by setting this attribute to “true”. Default: false |
allowRowTests | true/false | Specifies if "row tests" should be generated for scenario outlines. This setting is ignored if the unit test framework does not support row based testing. Default: true |
This section can be used to specify various test execution options.
Attribute | Value | Description |
---|---|---|
detectAmbiguousMatches | true/false | Specifies whether SpecFlow should report an error if there is an ambiguous match of step binding or just use the first one that matches. Default: true |
stopAtFirstError | true/false | Specifies whether the execution should stop at the first error or should continue to try matching the subsequent steps (in order to detect missing steps). Default: false |
missingOrPendingStepsOutcome | Inconclusive/Ignore/Error | Specifies how SpecFlow should behave if a step binding is not implemented or pending. See Missing, Pending or Improperly Configured Bindings. Default: Inconclusive |
This section can be used to configure how and what should SpecFlow trace out to the unit test output.
Attribute | Value | Description |
---|---|---|
traceSuccessfulSteps | true/false | Specifies whether SpecFlow should trace successful step binding executions. Default: true |
traceTimings | true/false | Specifies whether SpecFlow should trace execution time of the binding methods (only if the execution time is longer than the minTracedDuration value). Default: false |
minTracedDuration | TimeSpan (0:0:0.1) | Specifies a threshold for tracing the binding execution times. Default: 0:0:0.1 (100 ms) |
Listener | class name | An assembly qualified class name of a class that implements
TechTalk.SpecFlow.Tracing.ITraceListener interface. SpecFlow provides DefaultListener and NullListener as default implementations.
Default: TechTalk.SpecFlow.Tracing.DefaultListener, TechTalk.SpecFlow
|