-
Notifications
You must be signed in to change notification settings - Fork 754
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add app.config configuration for Cucumber-Messages (#1759)
* update submodule * add specs and bindings * add app.config dtos * convert into SpecFlowConfiguration & unit tests for it * make app.config scenarios only available for full framework * update vswhere * fix cucumber messages specs * remove unnecessary csproj changes
- Loading branch information
1 parent
5f66c61
commit c227205
Showing
10 changed files
with
296 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
TechTalk.SpecFlow/Configuration/AppConfig/CucumberMessageSinkElement.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using System.Configuration; | ||
|
||
namespace TechTalk.SpecFlow.Configuration.AppConfig | ||
{ | ||
public class CucumberMessageSinkElement : ConfigurationElement | ||
{ | ||
[ConfigurationProperty("type", IsRequired = true)] | ||
public string Type | ||
{ | ||
get => (string) this["type"]; | ||
set => this["type"] = value; | ||
} | ||
|
||
[ConfigurationProperty("path", IsRequired = true)] | ||
public string Path | ||
{ | ||
get => (string) this["path"]; | ||
set => this["path"] = value; | ||
} | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
TechTalk.SpecFlow/Configuration/AppConfig/CucumberMessagesElement.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using System.Collections.Generic; | ||
using System.Configuration; | ||
|
||
namespace TechTalk.SpecFlow.Configuration.AppConfig | ||
{ | ||
public class CucumberMessagesElement : ConfigurationElement | ||
{ | ||
[ConfigurationProperty("enabled", DefaultValue = false, IsRequired = false)] | ||
public bool Enabled | ||
{ | ||
get => (bool)this["enabled"]; | ||
set => this["enabled"] = value; | ||
} | ||
|
||
[ConfigurationProperty("sinks", IsDefaultCollection = false, IsRequired = false)] | ||
[ConfigurationCollection(typeof(CucumberMessagesSinkCollection), AddItemName = "sink")] | ||
public CucumberMessagesSinkCollection Sinks | ||
{ | ||
get => (CucumberMessagesSinkCollection) this["sinks"]; | ||
set => this["sinks"] = value; | ||
} | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
TechTalk.SpecFlow/Configuration/AppConfig/CucumberMessagesSinkCollection.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using System.Configuration; | ||
|
||
namespace TechTalk.SpecFlow.Configuration.AppConfig | ||
{ | ||
public class CucumberMessagesSinkCollection : ConfigurationElementCollection | ||
{ | ||
protected override ConfigurationElement CreateNewElement() | ||
{ | ||
return new CucumberMessageSinkElement(); | ||
} | ||
|
||
protected override object GetElementKey(ConfigurationElement element) | ||
{ | ||
var cucumberMessageSinkElement = ((CucumberMessageSinkElement)element); | ||
return cucumberMessageSinkElement.Type + cucumberMessageSinkElement.Path; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
....SpecFlow.Specs/Features/Configuration/Cucumber-Messages App.Config Configuration.feature
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
@fullframework | ||
Feature: Cucumber-Messages Configuration via app.config | ||
|
||
Cucumber-messages can be configured in the SpecFlow section of the app.config file to enable/disable messages | ||
and configure alternative output sinks | ||
|
||
Scenario: No configuration creates no output file | ||
|
||
Given there is a project with this app.config configuration | ||
""" | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<configuration> | ||
<configSections> | ||
<section name="specFlow" type="TechTalk.SpecFlow.Configuration.ConfigurationSectionHandler, TechTalk.SpecFlow" /> | ||
</configSections> | ||
<specFlow> | ||
<cucumber-messages /> | ||
</specFlow> | ||
</configuration> | ||
""" | ||
When the test suite is executed | ||
Then no Cucumber-Messages file is created | ||
|
||
Scenario: Disabled configuration creates no output file | ||
Given there is a project with this app.config configuration | ||
""" | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<configuration> | ||
<configSections> | ||
<section name="specFlow" type="TechTalk.SpecFlow.Configuration.ConfigurationSectionHandler, TechTalk.SpecFlow" /> | ||
</configSections> | ||
<specFlow> | ||
<cucumber-messages enabled="false" /> | ||
</specFlow> | ||
</configuration> | ||
""" | ||
When the test suite is executed | ||
Then no Cucumber-Messages file is created | ||
|
||
Scenario: Enabled configuration with no sinks configured create default output file | ||
The default Cucumber-Messages file is created at `cucumbermessages\messages` relative to the output directory | ||
|
||
Given there is a project with this app.config configuration | ||
""" | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<configuration> | ||
<configSections> | ||
<section name="specFlow" type="TechTalk.SpecFlow.Configuration.ConfigurationSectionHandler, TechTalk.SpecFlow" /> | ||
</configSections> | ||
<specFlow> | ||
<cucumber-messages enabled="true" /> | ||
</specFlow> | ||
</configuration> | ||
""" | ||
When the test suite is executed | ||
Then the Cucumber-Messages file 'cucumbermessages\messages' is created | ||
|
||
Scenario: Configured sinks are respected | ||
Given there is a project with this app.config configuration | ||
""" | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<configuration> | ||
<configSections> | ||
<section name="specFlow" type="TechTalk.SpecFlow.Configuration.ConfigurationSectionHandler, TechTalk.SpecFlow" /> | ||
</configSections> | ||
<specFlow> | ||
<cucumber-messages enabled="true" > | ||
<sinks> | ||
<sink type="file" path="custom_cucumber_messages_file.cm" /> | ||
</sinks> | ||
</cucumber-messages> | ||
</specFlow> | ||
</configuration> | ||
""" | ||
When the test suite is executed | ||
Then the Cucumber-Messages file 'custom_cucumber_messages_file.cm' is created | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters