From 21c2d00a47c639c784d48985c1bf214c383cb90b Mon Sep 17 00:00:00 2001 From: Sandor Tardi Date: Mon, 27 Sep 2021 20:28:52 +0200 Subject: [PATCH] (#2499) remove cucumber messages (#2499) remove cucumber messages config (#2499) remove cucumber submodule (#2499) update changelog, adjust documentation --- .gitignore | 9 - .gitmodules | 5 +- .../SpecFlow.TestProjectGenerator | 2 +- ExternalRepositories/cucumber | 1 - GitExtensions.settings | 60 +-- .../AppConfig/AppConfigConfigurationLoader.cs | 14 +- .../AppConfig/ConfigurationSectionHandler.cs | 7 - .../AppConfig/CucumberMessageSinkElement.cs | 21 - .../AppConfig/CucumberMessagesElement.cs | 23 -- .../CucumberMessagesSinkCollection.cs | 18 - .../Configuration/ConfigurationLoader.cs | 3 +- .../CucumberMessagesConfiguration.cs | 22 - .../JsonConfig/CucumberMessageSinkElement.cs | 13 - .../JsonConfig/CucumberMessagesElement.cs | 16 - .../Configuration/JsonConfig/JsonConfig.cs | 3 - .../JsonConfig/JsonConfigurationLoader.cs | 17 +- .../Configuration/SpecFlowConfiguration.cs | 43 +- .../CucumberMessageFactory.cs | 147 ------- .../CucumberMessages/CucumberMessageSender.cs | 111 ------ .../CucumberMessages/FieldValueProvider.cs | 99 ----- .../ICucumberMessageFactory.cs | 25 -- .../ICucumberMessageSender.cs | 16 - .../CucumberMessages/ICucumberMessageSink.cs | 9 - .../CucumberMessages/IFieldValueProvider.cs | 14 - .../CucumberMessages/IPickleIdGenerator.cs | 9 - .../CucumberMessages/IPickleIdStore.cs | 9 - .../IPickleIdStoreDictionaryFactory.cs | 10 - .../CucumberMessages/IPlatformFactory.cs | 10 - .../ISpecFlowVersionInformationProvider.cs | 7 - .../ISystemInformationProvider.cs | 8 - .../ITestAmbiguousMessageFactory.cs | 7 - .../ITestErrorMessageFactory.cs | 7 - .../CucumberMessages/ITestResultFactory.cs | 10 - .../ITestResultPartsFactory.cs | 15 - .../ITestRunResultCollector.cs | 14 - .../ITestRunResultSuccessCalculator.cs | 7 - ...NonStrictTestRunResultSuccessCalculator.cs | 11 - .../CucumberMessages/PickleIdGenerator.cs | 12 - .../CucumberMessages/PickleIdStore.cs | 51 --- .../PickleIdStoreDictionaryFactory.cs | 14 - .../CucumberMessages/PlatformFactory.cs | 30 -- .../CucumberMessages/SinkProvider.cs | 60 --- .../Sinks/IProtobufFileNameResolver.cs | 9 - .../Sinks/IProtobufFileSinkOutput.cs | 11 - .../Sinks/ProtobufFileNameResolver.cs | 39 -- .../Sinks/ProtobufFileSink.cs | 47 --- .../Sinks/ProtobufFileSinkConfiguration.cs | 12 - .../Sinks/ProtobufFileSinkOutput.cs | 61 --- .../SpecFlowVersionInformationProvider.cs | 11 - .../StrictTestRunResultSuccessCalculator.cs | 13 - .../SystemInformationProvider.cs | 19 - .../TestAmbiguousMessageFactory.cs | 10 - .../TestErrorMessageFactory.cs | 12 - .../CucumberMessages/TestResultFactory.cs | 42 -- .../TestResultPartsFactory.cs | 84 ---- .../CucumberMessages/TestRunResult.cs | 27 -- .../TestRunResultCollector.cs | 72 ---- TechTalk.SpecFlow/DateTimeExtensions.cs | 26 +- .../DefaultDependencyProvider.cs | 22 +- .../ITestPendingMessageFactory.cs | 2 +- .../ITestUndefinedMessageFactory.cs | 2 +- .../Infrastructure/TestExecutionEngine.cs | 49 +-- .../TestPendingMessageFactory.cs | 2 +- .../TestUndefinedMessageFactory.cs | 2 +- TechTalk.SpecFlow/SpecFlow.nuspec | 2 - TechTalk.SpecFlow/TechTalk.SpecFlow.csproj | 1 - .../Bindings/CultureInfoScopeTests.cs | 2 +- .../Configuration/AppConfigTests.cs | 125 ------ .../Configuration/JsonConfigTests.cs | 144 +------ .../CucumberMessageFactoryTests.cs | 377 ------------------ .../CucumberMessageSenderTests.cs | 170 -------- ...rictTestRunResultSuccessCalculatorTests.cs | 60 --- .../CucumberMessages/PickleIdStoreTests.cs | 88 ---- .../CucumberMessages/PlatformFactoryTests.cs | 100 ----- .../CucumberMessages/SinkProviderTests.cs | 81 ---- .../Sinks/ProtobufFileSinkOutputTests.cs | 90 ----- ...rictTestRunResultSuccessCalculatorTests.cs | 38 -- .../TestResultFactoryTests.cs | 90 ----- .../TestResultPartFactoryTestsAmbiguous.cs | 58 --- .../TestResultPartFactoryTestsBase.cs | 64 --- .../TestResultPartFactoryTestsFailed.cs | 57 --- .../TestResultPartFactoryTestsPassed.cs | 60 --- .../TestResultPartFactoryTestsPending.cs | 57 --- .../TestResultPartFactoryTestsSkipped.cs | 55 --- .../TestResultPartFactoryTestsUndefined.cs | 58 --- .../CucumberMessages/TimestampExtensions.cs | 20 - .../TestExecutionEngineTests.cs | 31 +- .../Drivers/ConfigurationLoaderDriver.cs | 5 +- .../MessageValidationDriver.cs | 64 --- ...-Messages App.Config Configuration.feature | 81 ---- ...cumber-Messages Json Configuration.feature | 61 --- .../Configuration/No Configuration.feature | 10 - .../Features/Hooks/ScopedHooks.feature | 2 +- .../CucumberMessagesFileSteps.cs | 27 -- .../CucumberMessages/ScenarioSteps.cs | 80 ---- .../CucumberMessages/TestCaseFinishedSteps.cs | 58 --- .../CucumberMessages/TestCaseStartedSteps.cs | 71 ---- .../CucumberMessages/TestRunFinishedSteps.cs | 40 -- .../CucumberMessages/TestRunStartedSteps.cs | 68 ---- .../CucumberMessages/TestSuiteSteps.cs | 62 --- .../SpecFlowConfigurationSteps.cs | 10 +- .../TechTalk.SpecFlow.Specs.csproj | 24 -- Tests/TechTalk.SpecFlow.Specs/specflow.json | 5 - changelog.txt | 5 + docs/Tools/Cucumber-Messages.md | 91 ----- docs/index.rst | 3 +- nuget.config | 1 - 107 files changed, 90 insertions(+), 4069 deletions(-) delete mode 160000 ExternalRepositories/cucumber delete mode 100644 TechTalk.SpecFlow/Configuration/AppConfig/CucumberMessageSinkElement.cs delete mode 100644 TechTalk.SpecFlow/Configuration/AppConfig/CucumberMessagesElement.cs delete mode 100644 TechTalk.SpecFlow/Configuration/AppConfig/CucumberMessagesSinkCollection.cs delete mode 100644 TechTalk.SpecFlow/Configuration/CucumberMessagesConfiguration.cs delete mode 100644 TechTalk.SpecFlow/Configuration/JsonConfig/CucumberMessageSinkElement.cs delete mode 100644 TechTalk.SpecFlow/Configuration/JsonConfig/CucumberMessagesElement.cs delete mode 100644 TechTalk.SpecFlow/CucumberMessages/CucumberMessageFactory.cs delete mode 100644 TechTalk.SpecFlow/CucumberMessages/CucumberMessageSender.cs delete mode 100644 TechTalk.SpecFlow/CucumberMessages/FieldValueProvider.cs delete mode 100644 TechTalk.SpecFlow/CucumberMessages/ICucumberMessageFactory.cs delete mode 100644 TechTalk.SpecFlow/CucumberMessages/ICucumberMessageSender.cs delete mode 100644 TechTalk.SpecFlow/CucumberMessages/ICucumberMessageSink.cs delete mode 100644 TechTalk.SpecFlow/CucumberMessages/IFieldValueProvider.cs delete mode 100644 TechTalk.SpecFlow/CucumberMessages/IPickleIdGenerator.cs delete mode 100644 TechTalk.SpecFlow/CucumberMessages/IPickleIdStore.cs delete mode 100644 TechTalk.SpecFlow/CucumberMessages/IPickleIdStoreDictionaryFactory.cs delete mode 100644 TechTalk.SpecFlow/CucumberMessages/IPlatformFactory.cs delete mode 100644 TechTalk.SpecFlow/CucumberMessages/ISpecFlowVersionInformationProvider.cs delete mode 100644 TechTalk.SpecFlow/CucumberMessages/ISystemInformationProvider.cs delete mode 100644 TechTalk.SpecFlow/CucumberMessages/ITestAmbiguousMessageFactory.cs delete mode 100644 TechTalk.SpecFlow/CucumberMessages/ITestErrorMessageFactory.cs delete mode 100644 TechTalk.SpecFlow/CucumberMessages/ITestResultFactory.cs delete mode 100644 TechTalk.SpecFlow/CucumberMessages/ITestResultPartsFactory.cs delete mode 100644 TechTalk.SpecFlow/CucumberMessages/ITestRunResultCollector.cs delete mode 100644 TechTalk.SpecFlow/CucumberMessages/ITestRunResultSuccessCalculator.cs delete mode 100644 TechTalk.SpecFlow/CucumberMessages/NonStrictTestRunResultSuccessCalculator.cs delete mode 100644 TechTalk.SpecFlow/CucumberMessages/PickleIdGenerator.cs delete mode 100644 TechTalk.SpecFlow/CucumberMessages/PickleIdStore.cs delete mode 100644 TechTalk.SpecFlow/CucumberMessages/PickleIdStoreDictionaryFactory.cs delete mode 100644 TechTalk.SpecFlow/CucumberMessages/PlatformFactory.cs delete mode 100644 TechTalk.SpecFlow/CucumberMessages/SinkProvider.cs delete mode 100644 TechTalk.SpecFlow/CucumberMessages/Sinks/IProtobufFileNameResolver.cs delete mode 100644 TechTalk.SpecFlow/CucumberMessages/Sinks/IProtobufFileSinkOutput.cs delete mode 100644 TechTalk.SpecFlow/CucumberMessages/Sinks/ProtobufFileNameResolver.cs delete mode 100644 TechTalk.SpecFlow/CucumberMessages/Sinks/ProtobufFileSink.cs delete mode 100644 TechTalk.SpecFlow/CucumberMessages/Sinks/ProtobufFileSinkConfiguration.cs delete mode 100644 TechTalk.SpecFlow/CucumberMessages/Sinks/ProtobufFileSinkOutput.cs delete mode 100644 TechTalk.SpecFlow/CucumberMessages/SpecFlowVersionInformationProvider.cs delete mode 100644 TechTalk.SpecFlow/CucumberMessages/StrictTestRunResultSuccessCalculator.cs delete mode 100644 TechTalk.SpecFlow/CucumberMessages/SystemInformationProvider.cs delete mode 100644 TechTalk.SpecFlow/CucumberMessages/TestAmbiguousMessageFactory.cs delete mode 100644 TechTalk.SpecFlow/CucumberMessages/TestErrorMessageFactory.cs delete mode 100644 TechTalk.SpecFlow/CucumberMessages/TestResultFactory.cs delete mode 100644 TechTalk.SpecFlow/CucumberMessages/TestResultPartsFactory.cs delete mode 100644 TechTalk.SpecFlow/CucumberMessages/TestRunResult.cs delete mode 100644 TechTalk.SpecFlow/CucumberMessages/TestRunResultCollector.cs rename TechTalk.SpecFlow/{CucumberMessages => Infrastructure}/ITestPendingMessageFactory.cs (74%) rename TechTalk.SpecFlow/{CucumberMessages => Infrastructure}/ITestUndefinedMessageFactory.cs (77%) rename TechTalk.SpecFlow/{CucumberMessages => Infrastructure}/TestPendingMessageFactory.cs (93%) rename TechTalk.SpecFlow/{CucumberMessages => Infrastructure}/TestUndefinedMessageFactory.cs (97%) delete mode 100644 Tests/TechTalk.SpecFlow.RuntimeTests/CucumberMessages/CucumberMessageFactoryTests.cs delete mode 100644 Tests/TechTalk.SpecFlow.RuntimeTests/CucumberMessages/CucumberMessageSenderTests.cs delete mode 100644 Tests/TechTalk.SpecFlow.RuntimeTests/CucumberMessages/NonStrictTestRunResultSuccessCalculatorTests.cs delete mode 100644 Tests/TechTalk.SpecFlow.RuntimeTests/CucumberMessages/PickleIdStoreTests.cs delete mode 100644 Tests/TechTalk.SpecFlow.RuntimeTests/CucumberMessages/PlatformFactoryTests.cs delete mode 100644 Tests/TechTalk.SpecFlow.RuntimeTests/CucumberMessages/SinkProviderTests.cs delete mode 100644 Tests/TechTalk.SpecFlow.RuntimeTests/CucumberMessages/Sinks/ProtobufFileSinkOutputTests.cs delete mode 100644 Tests/TechTalk.SpecFlow.RuntimeTests/CucumberMessages/StrictTestRunResultSuccessCalculatorTests.cs delete mode 100644 Tests/TechTalk.SpecFlow.RuntimeTests/CucumberMessages/TestResultFactoryTests.cs delete mode 100644 Tests/TechTalk.SpecFlow.RuntimeTests/CucumberMessages/TestResultPartFactoryTestsAmbiguous.cs delete mode 100644 Tests/TechTalk.SpecFlow.RuntimeTests/CucumberMessages/TestResultPartFactoryTestsBase.cs delete mode 100644 Tests/TechTalk.SpecFlow.RuntimeTests/CucumberMessages/TestResultPartFactoryTestsFailed.cs delete mode 100644 Tests/TechTalk.SpecFlow.RuntimeTests/CucumberMessages/TestResultPartFactoryTestsPassed.cs delete mode 100644 Tests/TechTalk.SpecFlow.RuntimeTests/CucumberMessages/TestResultPartFactoryTestsPending.cs delete mode 100644 Tests/TechTalk.SpecFlow.RuntimeTests/CucumberMessages/TestResultPartFactoryTestsSkipped.cs delete mode 100644 Tests/TechTalk.SpecFlow.RuntimeTests/CucumberMessages/TestResultPartFactoryTestsUndefined.cs delete mode 100644 Tests/TechTalk.SpecFlow.RuntimeTests/CucumberMessages/TimestampExtensions.cs delete mode 100644 Tests/TechTalk.SpecFlow.Specs/Drivers/CucumberMessages/MessageValidationDriver.cs delete mode 100644 Tests/TechTalk.SpecFlow.Specs/Features/Configuration/Cucumber-Messages App.Config Configuration.feature delete mode 100644 Tests/TechTalk.SpecFlow.Specs/Features/Configuration/Cucumber-Messages Json Configuration.feature delete mode 100644 Tests/TechTalk.SpecFlow.Specs/Features/Configuration/No Configuration.feature delete mode 100644 Tests/TechTalk.SpecFlow.Specs/StepDefinitions/CucumberMessages/CucumberMessagesFileSteps.cs delete mode 100644 Tests/TechTalk.SpecFlow.Specs/StepDefinitions/CucumberMessages/ScenarioSteps.cs delete mode 100644 Tests/TechTalk.SpecFlow.Specs/StepDefinitions/CucumberMessages/TestCaseFinishedSteps.cs delete mode 100644 Tests/TechTalk.SpecFlow.Specs/StepDefinitions/CucumberMessages/TestCaseStartedSteps.cs delete mode 100644 Tests/TechTalk.SpecFlow.Specs/StepDefinitions/CucumberMessages/TestRunFinishedSteps.cs delete mode 100644 Tests/TechTalk.SpecFlow.Specs/StepDefinitions/CucumberMessages/TestRunStartedSteps.cs delete mode 100644 Tests/TechTalk.SpecFlow.Specs/StepDefinitions/CucumberMessages/TestSuiteSteps.cs delete mode 100644 Tests/TechTalk.SpecFlow.Specs/specflow.json delete mode 100644 docs/Tools/Cucumber-Messages.md diff --git a/.gitignore b/.gitignore index c79b3e893..7a4449ce3 100644 --- a/.gitignore +++ b/.gitignore @@ -364,8 +364,6 @@ Backup*/* UpgradeLog* .vs/* - - #SpecFlow Stuff /_NCrunch_TechTalk.SpecFlow_VS2013/StoredText !lib/** @@ -375,17 +373,10 @@ TechTalk.SpecFlow.sln.GhostDoc.xml Features.Generated/ GitExtensions.settings.backup -!lib/** -TechTalk.SpecFlow.Tools/app.config -TechTalk.SpecFlow.Tools/plugincompability.config -TechTalk.SpecFlow.sln.GhostDoc.xml -Features.Generated/ -GitExtensions.settings.backup /Installer/NuGetPackages/SpecFlow.Tools.MsBuild.Generation/build/SpecFlow.Tools.MsBuild.Generation.targets /Installer/NuGetPackages/SpecFlow.Tools.MsBuild.Generation/build/SpecFlow.Tools.MsBuild.Generation.props /Tests/TechTalk.SpecFlow.MsBuildNetSdk.IntegrationTests/Features/dummy.feature.cs *.feature.cs -/Tests/TechTalk.SpecFlow.Specs/Features/CucumberMessages *.AssemblyHooks.cs *.AssemblyHooks.vb diff --git a/.gitmodules b/.gitmodules index 5af3001dc..9df34676f 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,3 @@ [submodule "ExternalRepositories/SpecFlow.TestProjectGenerator"] path = ExternalRepositories/SpecFlow.TestProjectGenerator - url = https://github.com/SpecFlowOSS/SpecFlow.TestProjectGenerator.git -[submodule "ExternalRepositories/cucumber"] - path = ExternalRepositories/cucumber - url = https://github.com/SpecFlowOSS/cucumber.git + url = https://github.com/SpecFlowOSS/SpecFlow.TestProjectGenerator.git \ No newline at end of file diff --git a/ExternalRepositories/SpecFlow.TestProjectGenerator b/ExternalRepositories/SpecFlow.TestProjectGenerator index df28da2f8..2fdb00041 160000 --- a/ExternalRepositories/SpecFlow.TestProjectGenerator +++ b/ExternalRepositories/SpecFlow.TestProjectGenerator @@ -1 +1 @@ -Subproject commit df28da2f8b53df6ac565c1cd243ef80500d6b737 +Subproject commit 2fdb00041cc407e34d3b3fb93a31de3d00266949 diff --git a/ExternalRepositories/cucumber b/ExternalRepositories/cucumber deleted file mode 160000 index d48650ad0..000000000 --- a/ExternalRepositories/cucumber +++ /dev/null @@ -1 +0,0 @@ -Subproject commit d48650ad0a20348de6f93a99d264f0b1ff889f40 diff --git a/GitExtensions.settings b/GitExtensions.settings index 0745e54c0..e29aa7d83 100644 --- a/GitExtensions.settings +++ b/GitExtensions.settings @@ -70,60 +70,60 @@ <?xml version="1.0" encoding="utf-16"?> -<ArrayOfGitExtLinkDef xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> +<ArrayOfGitExtLinkDef> <GitExtLinkDef> - <SearchInParts> - <RevisionPart>Message</RevisionPart> - <RevisionPart>LocalBranches</RevisionPart> - <RevisionPart>RemoteBranches</RevisionPart> - </SearchInParts> - <RemoteSearchInParts /> - <LinkFormats> - <GitExtLinkFormat> - <Caption>Issue {0}</Caption> - <Format>https://github.com/techtalk/SpecFlow/issues/{0}</Format> - </GitExtLinkFormat> - </LinkFormats> - <Name>GitHub - issues</Name> - <SearchPattern>(\s*(,|and)?\s*#\d+)+</SearchPattern> - <NestedSearchPattern>(\d+)+</NestedSearchPattern> <Enabled>true</Enabled> - <UseOnlyFirstRemote>false</UseOnlyFirstRemote> - </GitExtLinkDef> - <GitExtLinkDef> - <SearchInParts> - <RevisionPart>Message</RevisionPart> - </SearchInParts> - <RemoteSearchInParts /> <LinkFormats> <GitExtLinkFormat> <Caption>View on GitHub</Caption> - <Format>https://github.com/techtalk/SpecFlow/commit/%COMMIT_HASH%</Format> + <Format>https://github.com/SpecFlowOSS/SpecFlow/commit/%COMMIT_HASH%</Format> </GitExtLinkFormat> </LinkFormats> <Name>GitHub - commit</Name> - <SearchPattern>.*</SearchPattern> <NestedSearchPattern /> - <Enabled>true</Enabled> + <RemoteSearchInParts /> + <SearchInParts> + <RevisionPart>Message</RevisionPart> + </SearchInParts> + <SearchPattern>.*</SearchPattern> <UseOnlyFirstRemote>false</UseOnlyFirstRemote> </GitExtLinkDef> <GitExtLinkDef> + <Enabled>true</Enabled> + <LinkFormats> + <GitExtLinkFormat> + <Caption>Issue {0}</Caption> + <Format>https://github.com/SpecFlowOSS/SpecFlow/issues/{0}</Format> + </GitExtLinkFormat> + </LinkFormats> + <Name>GitHub - issues</Name> + <NestedSearchPattern>(\d+)+</NestedSearchPattern> + <RemoteSearchInParts /> <SearchInParts> <RevisionPart>Message</RevisionPart> <RevisionPart>LocalBranches</RevisionPart> <RevisionPart>RemoteBranches</RevisionPart> </SearchInParts> - <RemoteSearchInParts /> + <SearchPattern>(\s*(,|and)?\s*#\d+)+</SearchPattern> + <UseOnlyFirstRemote>false</UseOnlyFirstRemote> + </GitExtLinkDef> + <GitExtLinkDef> + <Enabled>true</Enabled> <LinkFormats> <GitExtLinkFormat> <Caption>PR {0}</Caption> - <Format>https://github.com/techtalk/SpecFlow/pull/{0}</Format> + <Format>https://github.com/SpecFlowOSS/SpecFlow/pull/{0}</Format> </GitExtLinkFormat> </LinkFormats> <Name>GitHub - PR</Name> - <SearchPattern>Merge pull request (\s*(,|and)?\s*#\d+)+</SearchPattern> <NestedSearchPattern>(\d+)+</NestedSearchPattern> - <Enabled>true</Enabled> + <RemoteSearchInParts /> + <SearchInParts> + <RevisionPart>Message</RevisionPart> + <RevisionPart>LocalBranches</RevisionPart> + <RevisionPart>RemoteBranches</RevisionPart> + </SearchInParts> + <SearchPattern>Merge pull request (\s*(,|and)?\s*#\d+)+</SearchPattern> <UseOnlyFirstRemote>false</UseOnlyFirstRemote> </GitExtLinkDef> </ArrayOfGitExtLinkDef> diff --git a/TechTalk.SpecFlow/Configuration/AppConfig/AppConfigConfigurationLoader.cs b/TechTalk.SpecFlow/Configuration/AppConfig/AppConfigConfigurationLoader.cs index 464e9072e..090de8c6e 100644 --- a/TechTalk.SpecFlow/Configuration/AppConfig/AppConfigConfigurationLoader.cs +++ b/TechTalk.SpecFlow/Configuration/AppConfig/AppConfigConfigurationLoader.cs @@ -32,7 +32,6 @@ public Configuration.SpecFlowConfiguration LoadAppConfig(Configuration.SpecFlowC bool allowDebugGeneratedFiles = specFlowConfiguration.AllowDebugGeneratedFiles; string[] addNonParallelizableMarkerForTags = specFlowConfiguration.AddNonParallelizableMarkerForTags; - CucumberMessagesConfiguration cucumberMessagesConfiguration = specFlowConfiguration.CucumberMessagesConfiguration; if (IsSpecified(configSection.Language)) { @@ -91,16 +90,6 @@ public Configuration.SpecFlowConfiguration LoadAppConfig(Configuration.SpecFlowC additionalStepAssemblies.Add(assemblyName); } - if (IsSpecified(configSection.CucumberMessages)) - { - cucumberMessagesConfiguration.Enabled = configSection.CucumberMessages.Enabled; - - foreach (CucumberMessageSinkElement cucumberMessagesSink in configSection.CucumberMessages.Sinks) - { - cucumberMessagesConfiguration.Sinks.Add(new CucumberMessagesSink(cucumberMessagesSink.Type, cucumberMessagesSink.Path)); - } - } - return new SpecFlowConfiguration(ConfigSource.AppConfig, runtimeContainerRegistrationCollection, generatorContainerRegistrationCollection, @@ -116,8 +105,7 @@ public Configuration.SpecFlowConfiguration LoadAppConfig(Configuration.SpecFlowC allowDebugGeneratedFiles, allowRowTests, addNonParallelizableMarkerForTags, - obsoleteBehavior, - cucumberMessagesConfiguration + obsoleteBehavior ); } diff --git a/TechTalk.SpecFlow/Configuration/AppConfig/ConfigurationSectionHandler.cs b/TechTalk.SpecFlow/Configuration/AppConfig/ConfigurationSectionHandler.cs index e14755a6a..b61fab456 100644 --- a/TechTalk.SpecFlow/Configuration/AppConfig/ConfigurationSectionHandler.cs +++ b/TechTalk.SpecFlow/Configuration/AppConfig/ConfigurationSectionHandler.cs @@ -50,13 +50,6 @@ public StepAssemblyCollection StepAssemblies set { this["stepAssemblies"] = value; } } - [ConfigurationProperty("cucumber-messages", IsRequired = false)] - public CucumberMessagesElement CucumberMessages - { - get => (CucumberMessagesElement)this["cucumber-messages"]; - set => this["cucumber-messages"] = value; - } - public static ConfigurationSectionHandler CreateFromXml(string xmlContent) { ConfigurationSectionHandler section = new ConfigurationSectionHandler(); diff --git a/TechTalk.SpecFlow/Configuration/AppConfig/CucumberMessageSinkElement.cs b/TechTalk.SpecFlow/Configuration/AppConfig/CucumberMessageSinkElement.cs deleted file mode 100644 index 2f57f3f9e..000000000 --- a/TechTalk.SpecFlow/Configuration/AppConfig/CucumberMessageSinkElement.cs +++ /dev/null @@ -1,21 +0,0 @@ -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; - } - } -} \ No newline at end of file diff --git a/TechTalk.SpecFlow/Configuration/AppConfig/CucumberMessagesElement.cs b/TechTalk.SpecFlow/Configuration/AppConfig/CucumberMessagesElement.cs deleted file mode 100644 index 7f25adb22..000000000 --- a/TechTalk.SpecFlow/Configuration/AppConfig/CucumberMessagesElement.cs +++ /dev/null @@ -1,23 +0,0 @@ -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; - } - } -} \ No newline at end of file diff --git a/TechTalk.SpecFlow/Configuration/AppConfig/CucumberMessagesSinkCollection.cs b/TechTalk.SpecFlow/Configuration/AppConfig/CucumberMessagesSinkCollection.cs deleted file mode 100644 index 747e129b7..000000000 --- a/TechTalk.SpecFlow/Configuration/AppConfig/CucumberMessagesSinkCollection.cs +++ /dev/null @@ -1,18 +0,0 @@ -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; - } - } -} \ No newline at end of file diff --git a/TechTalk.SpecFlow/Configuration/ConfigurationLoader.cs b/TechTalk.SpecFlow/Configuration/ConfigurationLoader.cs index b85ebab8e..141dc3a15 100644 --- a/TechTalk.SpecFlow/Configuration/ConfigurationLoader.cs +++ b/TechTalk.SpecFlow/Configuration/ConfigurationLoader.cs @@ -137,8 +137,7 @@ public static SpecFlowConfiguration GetDefault() DefaultAllowDebugGeneratedFiles, DefaultAllowRowTests, DefaultAddNonParallelizableMarkerForTags, - DefaultObsoleteBehavior, - new CucumberMessagesConfiguration() + DefaultObsoleteBehavior ); } diff --git a/TechTalk.SpecFlow/Configuration/CucumberMessagesConfiguration.cs b/TechTalk.SpecFlow/Configuration/CucumberMessagesConfiguration.cs deleted file mode 100644 index cb83c3edf..000000000 --- a/TechTalk.SpecFlow/Configuration/CucumberMessagesConfiguration.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System.Collections.Generic; - -namespace TechTalk.SpecFlow.Configuration -{ - public class CucumberMessagesConfiguration - { - public bool Enabled { get; set; } - public List Sinks { get; set; } = new List(); - } - - public class CucumberMessagesSink - { - public CucumberMessagesSink(string type, string path) - { - Type = type; - Path = path; - } - - public string Type { get; } - public string Path { get; } - } -} \ No newline at end of file diff --git a/TechTalk.SpecFlow/Configuration/JsonConfig/CucumberMessageSinkElement.cs b/TechTalk.SpecFlow/Configuration/JsonConfig/CucumberMessageSinkElement.cs deleted file mode 100644 index 404dea750..000000000 --- a/TechTalk.SpecFlow/Configuration/JsonConfig/CucumberMessageSinkElement.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System.Runtime.Serialization; - -namespace TechTalk.SpecFlow.Configuration.JsonConfig -{ - public class CucumberMessageSinkElement - { - [DataMember(Name = "type")] - public string Type { get; set; } - - [DataMember(Name = "path")] - public string Path { get; set; } - } -} \ No newline at end of file diff --git a/TechTalk.SpecFlow/Configuration/JsonConfig/CucumberMessagesElement.cs b/TechTalk.SpecFlow/Configuration/JsonConfig/CucumberMessagesElement.cs deleted file mode 100644 index 8d14fa4bc..000000000 --- a/TechTalk.SpecFlow/Configuration/JsonConfig/CucumberMessagesElement.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System.Collections.Generic; -using System.ComponentModel; -using System.Runtime.Serialization; - -namespace TechTalk.SpecFlow.Configuration.JsonConfig -{ - public class CucumberMessagesElement - { - [DefaultValue(false)] - [DataMember(Name = "enabled")] - public bool Enabled { get; set; } - - [DataMember(Name = "sinks")] - public List Sinks { get; set; } - } -} \ No newline at end of file diff --git a/TechTalk.SpecFlow/Configuration/JsonConfig/JsonConfig.cs b/TechTalk.SpecFlow/Configuration/JsonConfig/JsonConfig.cs index eaec00ad5..854826096 100644 --- a/TechTalk.SpecFlow/Configuration/JsonConfig/JsonConfig.cs +++ b/TechTalk.SpecFlow/Configuration/JsonConfig/JsonConfig.cs @@ -22,8 +22,5 @@ public class JsonConfig [DataMember(Name = "stepAssemblies")] public List StepAssemblies { get; set; } - - [DataMember(Name = "cucumber-messages")] - public CucumberMessagesElement CucumberMessages { get; set; } } } \ No newline at end of file diff --git a/TechTalk.SpecFlow/Configuration/JsonConfig/JsonConfigurationLoader.cs b/TechTalk.SpecFlow/Configuration/JsonConfig/JsonConfigurationLoader.cs index 435d8c001..3be5c9b85 100644 --- a/TechTalk.SpecFlow/Configuration/JsonConfig/JsonConfigurationLoader.cs +++ b/TechTalk.SpecFlow/Configuration/JsonConfig/JsonConfigurationLoader.cs @@ -30,7 +30,6 @@ public SpecFlowConfiguration LoadJson(SpecFlowConfiguration specFlowConfiguratio bool allowDebugGeneratedFiles = specFlowConfiguration.AllowDebugGeneratedFiles; var addNonParallelizableMarkerForTags = specFlowConfiguration.AddNonParallelizableMarkerForTags; var obsoleteBehavior = specFlowConfiguration.ObsoleteBehavior; - var cucumberMessagesConfiguration = specFlowConfiguration.CucumberMessagesConfiguration; if (jsonConfig.Language != null) { @@ -86,19 +85,6 @@ public SpecFlowConfiguration LoadJson(SpecFlowConfiguration specFlowConfiguratio } } - if (jsonConfig.CucumberMessages != null) - { - cucumberMessagesConfiguration.Enabled = jsonConfig.CucumberMessages.Enabled; - - if (jsonConfig.CucumberMessages.Sinks != null) - { - foreach (var cucumberMessageSinkElement in jsonConfig.CucumberMessages.Sinks) - { - cucumberMessagesConfiguration.Sinks.Add(new CucumberMessagesSink(cucumberMessageSinkElement.Type, cucumberMessageSinkElement.Path)); - } - } - } - return new SpecFlowConfiguration( ConfigSource.Json, containerRegistrationCollection, @@ -115,8 +101,7 @@ public SpecFlowConfiguration LoadJson(SpecFlowConfiguration specFlowConfiguratio allowDebugGeneratedFiles, allowRowTests, addNonParallelizableMarkerForTags, - obsoleteBehavior, - cucumberMessagesConfiguration + obsoleteBehavior ); } } diff --git a/TechTalk.SpecFlow/Configuration/SpecFlowConfiguration.cs b/TechTalk.SpecFlow/Configuration/SpecFlowConfiguration.cs index eca91bd07..d1ea1292e 100644 --- a/TechTalk.SpecFlow/Configuration/SpecFlowConfiguration.cs +++ b/TechTalk.SpecFlow/Configuration/SpecFlowConfiguration.cs @@ -31,10 +31,8 @@ public SpecFlowConfiguration(ConfigSource configSource, bool allowDebugGeneratedFiles, bool allowRowTests, string[] addNonParallelizableMarkerForTags, - ObsoleteBehavior obsoleteBehavior, - CucumberMessagesConfiguration cucumberMessagesConfiguration) + ObsoleteBehavior obsoleteBehavior) { - CucumberMessagesConfiguration = cucumberMessagesConfiguration; ConfigSource = configSource; CustomDependencies = customDependencies; GeneratorCustomDependencies = generatorCustomDependencies; @@ -53,14 +51,11 @@ public SpecFlowConfiguration(ConfigSource configSource, ObsoleteBehavior = obsoleteBehavior; } - public CucumberMessagesConfiguration CucumberMessagesConfiguration { get; } - public ConfigSource ConfigSource { get; set; } public ContainerRegistrationCollection CustomDependencies { get; set; } public ContainerRegistrationCollection GeneratorCustomDependencies { get; set; } - //language settings public CultureInfo FeatureLanguage { get; set; } public CultureInfo BindingCulture { get; set; } @@ -83,15 +78,22 @@ public SpecFlowConfiguration(ConfigSource configSource, public List AdditionalStepAssemblies { get; set; } - protected bool Equals(SpecFlowConfiguration other) - { - return Equals(CucumberMessagesConfiguration, other.CucumberMessagesConfiguration) && ConfigSource == other.ConfigSource && Equals(CustomDependencies, other.CustomDependencies) && - Equals(GeneratorCustomDependencies, other.GeneratorCustomDependencies) && Equals(FeatureLanguage, other.FeatureLanguage) && Equals(BindingCulture, other.BindingCulture) && - StopAtFirstError == other.StopAtFirstError && MissingOrPendingStepsOutcome == other.MissingOrPendingStepsOutcome && AllowDebugGeneratedFiles == other.AllowDebugGeneratedFiles && - AllowRowTests == other.AllowRowTests && ObsoleteBehavior == other.ObsoleteBehavior && TraceSuccessfulSteps == other.TraceSuccessfulSteps && TraceTimings == other.TraceTimings && - MinTracedDuration.Equals(other.MinTracedDuration) && StepDefinitionSkeletonStyle == other.StepDefinitionSkeletonStyle && - AdditionalStepAssemblies.SequenceEqual(other.AdditionalStepAssemblies) && AddNonParallelizableMarkerForTags.SequenceEqual(other.AddNonParallelizableMarkerForTags); - } + protected bool Equals(SpecFlowConfiguration other) => ConfigSource == other.ConfigSource + && Equals(CustomDependencies, other.CustomDependencies) + && Equals(GeneratorCustomDependencies, other.GeneratorCustomDependencies) + && Equals(FeatureLanguage, other.FeatureLanguage) + && Equals(BindingCulture, other.BindingCulture) + && StopAtFirstError == other.StopAtFirstError + && MissingOrPendingStepsOutcome == other.MissingOrPendingStepsOutcome + && AllowDebugGeneratedFiles == other.AllowDebugGeneratedFiles + && AllowRowTests == other.AllowRowTests + && ObsoleteBehavior == other.ObsoleteBehavior + && TraceSuccessfulSteps == other.TraceSuccessfulSteps + && TraceTimings == other.TraceTimings + && MinTracedDuration.Equals(other.MinTracedDuration) + && StepDefinitionSkeletonStyle == other.StepDefinitionSkeletonStyle + && AdditionalStepAssemblies.SequenceEqual(other.AdditionalStepAssemblies) + && AddNonParallelizableMarkerForTags.SequenceEqual(other.AddNonParallelizableMarkerForTags); public override bool Equals(object obj) { @@ -110,28 +112,27 @@ public override bool Equals(object obj) return false; } - return Equals((SpecFlowConfiguration) obj); + return Equals((SpecFlowConfiguration)obj); } public override int GetHashCode() { unchecked { - var hashCode = CucumberMessagesConfiguration != null ? CucumberMessagesConfiguration.GetHashCode() : 0; - hashCode = (hashCode * 397) ^ (int) ConfigSource; + var hashCode = (int)ConfigSource; hashCode = (hashCode * 397) ^ (CustomDependencies != null ? CustomDependencies.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (GeneratorCustomDependencies != null ? GeneratorCustomDependencies.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (FeatureLanguage != null ? FeatureLanguage.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (BindingCulture != null ? BindingCulture.GetHashCode() : 0); hashCode = (hashCode * 397) ^ StopAtFirstError.GetHashCode(); - hashCode = (hashCode * 397) ^ (int) MissingOrPendingStepsOutcome; + hashCode = (hashCode * 397) ^ (int)MissingOrPendingStepsOutcome; hashCode = (hashCode * 397) ^ AllowDebugGeneratedFiles.GetHashCode(); hashCode = (hashCode * 397) ^ AllowRowTests.GetHashCode(); - hashCode = (hashCode * 397) ^ (int) ObsoleteBehavior; + hashCode = (hashCode * 397) ^ (int)ObsoleteBehavior; hashCode = (hashCode * 397) ^ TraceSuccessfulSteps.GetHashCode(); hashCode = (hashCode * 397) ^ TraceTimings.GetHashCode(); hashCode = (hashCode * 397) ^ MinTracedDuration.GetHashCode(); - hashCode = (hashCode * 397) ^ (int) StepDefinitionSkeletonStyle; + hashCode = (hashCode * 397) ^ (int)StepDefinitionSkeletonStyle; hashCode = (hashCode * 397) ^ (AdditionalStepAssemblies != null ? AdditionalStepAssemblies.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (AddNonParallelizableMarkerForTags != null ? AddNonParallelizableMarkerForTags.GetHashCode() : 0); return hashCode; diff --git a/TechTalk.SpecFlow/CucumberMessages/CucumberMessageFactory.cs b/TechTalk.SpecFlow/CucumberMessages/CucumberMessageFactory.cs deleted file mode 100644 index 06226dd56..000000000 --- a/TechTalk.SpecFlow/CucumberMessages/CucumberMessageFactory.cs +++ /dev/null @@ -1,147 +0,0 @@ -using System; -using Google.Protobuf.WellKnownTypes; -using Io.Cucumber.Messages; -using TechTalk.SpecFlow.CommonModels; - -using static Io.Cucumber.Messages.TestCaseStarted.Types; -using Timestamp = Io.Cucumber.Messages.Timestamp; - -namespace TechTalk.SpecFlow.CucumberMessages -{ - public class CucumberMessageFactory : ICucumberMessageFactory - { - public string ConvertToPickleIdString(Guid id) - { - return $"{id:D}"; - } - - public IResult BuildTestRunStartedMessage(DateTime timeStamp) - { - if (timeStamp.Kind != DateTimeKind.Utc) - { - return Result.Failure($"{nameof(timeStamp)} must be an UTC {nameof(DateTime)}. It is {timeStamp.Kind}"); - } - - - - var testRunStarted = new TestRunStarted - { - Timestamp = timeStamp.ToCucumberMessagesTimestamp() - }; - - return Result.Success(testRunStarted); - } - - public IResult BuildTestCaseStartedMessage(Guid pickleId, DateTime timeStamp, Platform platform) - { - if (platform is null) - { - return Result.Failure($"The {nameof(platform)} parameter must not be null"); - } - - if (timeStamp.Kind != DateTimeKind.Utc) - { - return Result.Failure($"{nameof(timeStamp)} must be an UTC {nameof(DateTime)}. It is {timeStamp.Kind}"); - } - - var testCaseStarted = new TestCaseStarted - { - Timestamp = timeStamp.ToCucumberMessagesTimestamp(), - PickleId = ConvertToPickleIdString(pickleId), - Platform = platform - }; - - return Result.Success(testCaseStarted); - } - - public IResult BuildTestCaseFinishedMessage(Guid pickleId, DateTime timeStamp, TestResult testResult) - { - if (testResult is null) - { - return Result.Failure(new ArgumentNullException(nameof(testResult))); - } - - if (timeStamp.Kind != DateTimeKind.Utc) - { - return Result.Failure($"{nameof(timeStamp)} must be an UTC {nameof(DateTime)}. It is {timeStamp.Kind}"); - } - - var testCaseFinished = new TestCaseFinished - { - PickleId = ConvertToPickleIdString(pickleId), - Timestamp = timeStamp.ToCucumberMessagesTimestamp(), - TestResult = testResult - }; - - return Result.Success(testCaseFinished); - } - - public IResult BuildTestRunFinishedMessage(bool isSuccess, DateTime timeStamp) - { - if (timeStamp.Kind != DateTimeKind.Utc) - { - return Result.Failure($"{nameof(timeStamp)} must be an UTC {nameof(DateTime)}. It is {timeStamp.Kind}"); - } - - var testRunFinished = new TestRunFinished - { - Success = isSuccess, - Timestamp = timeStamp.ToCucumberMessagesTimestamp() - }; - - return Result.Success(testRunFinished); - } - - public IResult BuildEnvelopeMessage(IResult testRunStarted) - { - switch (testRunStarted) - { - case ISuccess success: - return Result.Success(new Envelope { TestRunStarted = success.Result }); - case IFailure failure: - return Result.Failure($"{nameof(testRunStarted)} must be an {nameof(ISuccess)}.", failure); - default: - return Result.Failure($"{nameof(testRunStarted)} must be an {nameof(ISuccess)}."); - } - } - - public IResult BuildEnvelopeMessage(IResult testCaseStarted) - { - switch (testCaseStarted) - { - case ISuccess success: - return Result.Success(new Envelope { TestCaseStarted = success.Result }); - case IFailure failure: - return Result.Failure($"{nameof(testCaseStarted)} must be an {nameof(ISuccess)}.", failure); - default: - return Result.Failure($"{nameof(testCaseStarted)} must be an {nameof(ISuccess)}."); - } - } - - public IResult BuildEnvelopeMessage(IResult testCaseFinished) - { - switch (testCaseFinished) - { - case ISuccess success: - return Result.Success(new Envelope { TestCaseFinished = success.Result }); - case IFailure failure: - return Result.Failure($"{nameof(testCaseFinished)} must be an {nameof(ISuccess)}.", failure); - default: - return Result.Failure($"{nameof(testCaseFinished)} must be an {nameof(ISuccess)}."); - } - } - - public IResult BuildEnvelopeMessage(IResult testRunFinished) - { - switch (testRunFinished) - { - case ISuccess success: - return Result.Success(new Envelope { TestRunFinished = success.Result }); - case IFailure failure: - return Result.Failure($"{nameof(testRunFinished)} must be an {nameof(ISuccess)}.", failure); - default: - return Result.Failure($"{nameof(testRunFinished)} must be an {nameof(ISuccess)}."); - } - } - } -} diff --git a/TechTalk.SpecFlow/CucumberMessages/CucumberMessageSender.cs b/TechTalk.SpecFlow/CucumberMessages/CucumberMessageSender.cs deleted file mode 100644 index 82e882c6b..000000000 --- a/TechTalk.SpecFlow/CucumberMessages/CucumberMessageSender.cs +++ /dev/null @@ -1,111 +0,0 @@ -using System; -using System.Collections.Generic; -using Io.Cucumber.Messages; -using TechTalk.SpecFlow.CommonModels; - -namespace TechTalk.SpecFlow.CucumberMessages -{ - public class CucumberMessageSender : ICucumberMessageSender - { - private readonly ICucumberMessageFactory _cucumberMessageFactory; - private readonly IPlatformFactory _platformFactory; - private readonly IFieldValueProvider _fieldValueProvider; - private readonly ITestRunResultSuccessCalculator _testRunResultSuccessCalculator; - - private readonly List _cucumberMessageSinks; - - private bool AnyReceivers => _cucumberMessageSinks.Count > 0; - - public CucumberMessageSender( - ICucumberMessageFactory cucumberMessageFactory, - IPlatformFactory platformFactory, - IFieldValueProvider fieldValueProvider, - ITestRunResultSuccessCalculator testRunResultSuccessCalculator, ISinkProvider sinkProvider) - { - _cucumberMessageFactory = cucumberMessageFactory ?? throw new ArgumentNullException(nameof(cucumberMessageFactory)); - _platformFactory = platformFactory; - _fieldValueProvider = fieldValueProvider; - _testRunResultSuccessCalculator = testRunResultSuccessCalculator; - _cucumberMessageSinks = sinkProvider.GetMessageSinksFromConfiguration(); - } - - public void SendTestRunStarted() - { - if (!AnyReceivers) - { - return; - } - - var nowDateAndTime = _fieldValueProvider.GetTestRunStartedTime(); - var testRunStartedMessageResult = _cucumberMessageFactory.BuildTestRunStartedMessage(nowDateAndTime); - var envelope = _cucumberMessageFactory.BuildEnvelopeMessage(testRunStartedMessageResult); - SendMessageOrThrowException(envelope); - } - - public void SendTestCaseStarted(ScenarioInfo scenarioInfo) - { - if (!AnyReceivers) - { - return; - } - - var actualPickleId = _fieldValueProvider.GetTestCaseStartedPickleId(scenarioInfo); - var nowDateAndTime = _fieldValueProvider.GetTestCaseStartedTime(); - - var platform = _platformFactory.BuildFromSystemInformation(); - - var testCaseStartedMessageResult = _cucumberMessageFactory.BuildTestCaseStartedMessage(actualPickleId, nowDateAndTime, platform); - var envelope = _cucumberMessageFactory.BuildEnvelopeMessage(testCaseStartedMessageResult); - SendMessageOrThrowException(envelope); - } - - public void SendTestCaseFinished(ScenarioInfo scenarioInfo, TestResult testResult) - { - if (!AnyReceivers) - { - return; - } - - var actualPickleId = _fieldValueProvider.GetTestCaseFinishedPickleId(scenarioInfo); - var nowDateAndTime = _fieldValueProvider.GetTestCaseFinishedTime(); - - var testCaseFinishedMessageResult = _cucumberMessageFactory.BuildTestCaseFinishedMessage(actualPickleId, nowDateAndTime, testResult); - var envelope = _cucumberMessageFactory.BuildEnvelopeMessage(testCaseFinishedMessageResult); - SendMessageOrThrowException(envelope); - } - - public void SendTestRunFinished(TestRunResult testRunResult) - { - if (!AnyReceivers) - { - return; - } - - var nowDateAndTime = _fieldValueProvider.GetTestRunFinishedTime(); - bool isSuccess = _testRunResultSuccessCalculator.IsSuccess(testRunResult); - - var testRunFinishedMessage = _cucumberMessageFactory.BuildTestRunFinishedMessage(isSuccess, nowDateAndTime); - var envelope = _cucumberMessageFactory.BuildEnvelopeMessage(testRunFinishedMessage); - SendMessageOrThrowException(envelope); - } - - private void SendMessageOrThrowException(IResult messageResult) - { - switch (messageResult) - { - case ISuccess success: - - foreach (var cucumberMessageSink in _cucumberMessageSinks) - { - cucumberMessageSink.SendMessage(success.Result); - } - break; - - case WrappedFailure failure: throw new InvalidOperationException($"The message could not be created. {failure}"); - case ExceptionFailure failure: throw failure.Exception; - case Failure failure: throw new InvalidOperationException($"The message could not be created. {failure.Description}"); - default: throw new InvalidOperationException("The message could not be created."); - } - } - } -} diff --git a/TechTalk.SpecFlow/CucumberMessages/FieldValueProvider.cs b/TechTalk.SpecFlow/CucumberMessages/FieldValueProvider.cs deleted file mode 100644 index 0460d64a9..000000000 --- a/TechTalk.SpecFlow/CucumberMessages/FieldValueProvider.cs +++ /dev/null @@ -1,99 +0,0 @@ -using System; -using System.Globalization; -using TechTalk.SpecFlow.CommonModels; -using TechTalk.SpecFlow.EnvironmentAccess; -using TechTalk.SpecFlow.Time; - -namespace TechTalk.SpecFlow.CucumberMessages -{ - public class FieldValueProvider : IFieldValueProvider - { - private const string SpecFlowMessagesTestRunStartedTimeOverrideName = "SpecFlow_Messages_TestRunStartedTimeOverride"; - private const string SpecFlowMessagesTestCaseStartedTimeOverrideName = "SpecFlow_Messages_TestCaseStartedTimeOverride"; - private const string SpecFlowMessagesTestCaseStartedPickleIdOverrideName = "SpecFlow_Messages_TestCaseStartedPickleIdOverride"; - private const string SpecFlowMessagesTestCaseFinishedTimeOverrideName = "SpecFlow_Messages_TestCaseFinishedTimeOverride"; - private const string SpecFlowMessagesTestCaseFinishedPickleIdOverrideName = "SpecFlow_Messages_TestCaseFinishedPickleIdOverride"; - private const string SpecFlowMessagesTestRunFinishedTimeOverrideName = "SpecFlow_Messages_TestRunFinishedTimeOverride"; - private readonly IEnvironmentWrapper _environmentWrapper; - private readonly IClock _clock; - private readonly IPickleIdStore _pickleIdStore; - - public FieldValueProvider(IEnvironmentWrapper environmentWrapper, IClock clock, IPickleIdStore pickleIdStore) - { - _environmentWrapper = environmentWrapper; - _clock = clock; - _pickleIdStore = pickleIdStore; - } - - public bool TryParseUniversalDateTime(string source, out DateTime result) - { - return DateTime.TryParse(source, DateTimeFormatInfo.InvariantInfo, DateTimeStyles.AdjustToUniversal | DateTimeStyles.AssumeUniversal, out result); - } - - public DateTime GetTestRunStartedTime() - { - if (_environmentWrapper.GetEnvironmentVariable(SpecFlowMessagesTestRunStartedTimeOverrideName) is ISuccess success - && TryParseUniversalDateTime(success.Result, out var dateTime)) - { - return dateTime; - } - - return _clock.GetNowDateAndTime(); - } - - public DateTime GetTestCaseStartedTime() - { - if (_environmentWrapper.GetEnvironmentVariable(SpecFlowMessagesTestCaseStartedTimeOverrideName) is ISuccess success - && TryParseUniversalDateTime(success.Result, out var dateTime)) - { - return dateTime; - } - - return _clock.GetNowDateAndTime(); - } - - public Guid GetTestCaseStartedPickleId(ScenarioInfo scenarioInfo) - { - if (_environmentWrapper.GetEnvironmentVariable(SpecFlowMessagesTestCaseStartedPickleIdOverrideName) is ISuccess success - && Guid.TryParse(success.Result, out var pickleId)) - { - return pickleId; - } - - return _pickleIdStore.GetPickleIdForScenario(scenarioInfo); - } - - public DateTime GetTestCaseFinishedTime() - { - if (_environmentWrapper.GetEnvironmentVariable(SpecFlowMessagesTestCaseFinishedTimeOverrideName) is ISuccess success - && TryParseUniversalDateTime(success.Result, out var dateTime)) - { - return dateTime; - } - - return _clock.GetNowDateAndTime(); - } - - public Guid GetTestCaseFinishedPickleId(ScenarioInfo scenarioInfo) - { - if (_environmentWrapper.GetEnvironmentVariable(SpecFlowMessagesTestCaseFinishedPickleIdOverrideName) is ISuccess success - && Guid.TryParse(success.Result, out var pickleId)) - { - return pickleId; - } - - return _pickleIdStore.GetPickleIdForScenario(scenarioInfo); - } - - public DateTime GetTestRunFinishedTime() - { - if (_environmentWrapper.GetEnvironmentVariable(SpecFlowMessagesTestRunFinishedTimeOverrideName) is ISuccess success - && TryParseUniversalDateTime(success.Result, out var dateTime)) - { - return dateTime; - } - - return _clock.GetNowDateAndTime(); - } - } -} diff --git a/TechTalk.SpecFlow/CucumberMessages/ICucumberMessageFactory.cs b/TechTalk.SpecFlow/CucumberMessages/ICucumberMessageFactory.cs deleted file mode 100644 index 0363d7fef..000000000 --- a/TechTalk.SpecFlow/CucumberMessages/ICucumberMessageFactory.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System; -using Io.Cucumber.Messages; -using TechTalk.SpecFlow.CommonModels; - -namespace TechTalk.SpecFlow.CucumberMessages -{ - public interface ICucumberMessageFactory - { - IResult BuildTestRunStartedMessage(DateTime timeStamp); - - IResult BuildTestCaseStartedMessage(Guid pickleId, DateTime timeStamp, TestCaseStarted.Types.Platform platform); - - IResult BuildTestCaseFinishedMessage(Guid pickleId, DateTime timeStamp, TestResult testResult); - - IResult BuildTestRunFinishedMessage(bool isSuccess, DateTime timeStamp); - - IResult BuildEnvelopeMessage(IResult testRunStarted); - - IResult BuildEnvelopeMessage(IResult testCaseStarted); - - IResult BuildEnvelopeMessage(IResult testCaseFinished); - - IResult BuildEnvelopeMessage(IResult testRunFinished); - } -} diff --git a/TechTalk.SpecFlow/CucumberMessages/ICucumberMessageSender.cs b/TechTalk.SpecFlow/CucumberMessages/ICucumberMessageSender.cs deleted file mode 100644 index 35d5f663d..000000000 --- a/TechTalk.SpecFlow/CucumberMessages/ICucumberMessageSender.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; -using Io.Cucumber.Messages; - -namespace TechTalk.SpecFlow.CucumberMessages -{ - public interface ICucumberMessageSender - { - void SendTestRunStarted(); - - void SendTestCaseStarted(ScenarioInfo scenarioInfo); - - void SendTestCaseFinished(ScenarioInfo scenarioInfo, TestResult testResult); - - void SendTestRunFinished(TestRunResult testRunResult); - } -} diff --git a/TechTalk.SpecFlow/CucumberMessages/ICucumberMessageSink.cs b/TechTalk.SpecFlow/CucumberMessages/ICucumberMessageSink.cs deleted file mode 100644 index 0ffbb1d1c..000000000 --- a/TechTalk.SpecFlow/CucumberMessages/ICucumberMessageSink.cs +++ /dev/null @@ -1,9 +0,0 @@ -using Io.Cucumber.Messages; - -namespace TechTalk.SpecFlow.CucumberMessages -{ - public interface ICucumberMessageSink - { - void SendMessage(Envelope message); - } -} diff --git a/TechTalk.SpecFlow/CucumberMessages/IFieldValueProvider.cs b/TechTalk.SpecFlow/CucumberMessages/IFieldValueProvider.cs deleted file mode 100644 index efdb73885..000000000 --- a/TechTalk.SpecFlow/CucumberMessages/IFieldValueProvider.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System; - -namespace TechTalk.SpecFlow.CucumberMessages -{ - public interface IFieldValueProvider - { - DateTime GetTestRunStartedTime(); - DateTime GetTestCaseStartedTime(); - Guid GetTestCaseStartedPickleId(ScenarioInfo scenarioInfo); - DateTime GetTestCaseFinishedTime(); - Guid GetTestCaseFinishedPickleId(ScenarioInfo scenarioInfo); - DateTime GetTestRunFinishedTime(); - } -} diff --git a/TechTalk.SpecFlow/CucumberMessages/IPickleIdGenerator.cs b/TechTalk.SpecFlow/CucumberMessages/IPickleIdGenerator.cs deleted file mode 100644 index a3514c484..000000000 --- a/TechTalk.SpecFlow/CucumberMessages/IPickleIdGenerator.cs +++ /dev/null @@ -1,9 +0,0 @@ -using System; - -namespace TechTalk.SpecFlow.CucumberMessages -{ - public interface IPickleIdGenerator - { - Guid GeneratePickleId(); - } -} diff --git a/TechTalk.SpecFlow/CucumberMessages/IPickleIdStore.cs b/TechTalk.SpecFlow/CucumberMessages/IPickleIdStore.cs deleted file mode 100644 index 236ad9866..000000000 --- a/TechTalk.SpecFlow/CucumberMessages/IPickleIdStore.cs +++ /dev/null @@ -1,9 +0,0 @@ -using System; - -namespace TechTalk.SpecFlow.CucumberMessages -{ - public interface IPickleIdStore - { - Guid GetPickleIdForScenario(ScenarioInfo scenarioInfo); - } -} diff --git a/TechTalk.SpecFlow/CucumberMessages/IPickleIdStoreDictionaryFactory.cs b/TechTalk.SpecFlow/CucumberMessages/IPickleIdStoreDictionaryFactory.cs deleted file mode 100644 index cb3e56cd5..000000000 --- a/TechTalk.SpecFlow/CucumberMessages/IPickleIdStoreDictionaryFactory.cs +++ /dev/null @@ -1,10 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace TechTalk.SpecFlow.CucumberMessages -{ - public interface IPickleIdStoreDictionaryFactory - { - IDictionary BuildDictionary(); - } -} diff --git a/TechTalk.SpecFlow/CucumberMessages/IPlatformFactory.cs b/TechTalk.SpecFlow/CucumberMessages/IPlatformFactory.cs deleted file mode 100644 index cecd14a35..000000000 --- a/TechTalk.SpecFlow/CucumberMessages/IPlatformFactory.cs +++ /dev/null @@ -1,10 +0,0 @@ -using Io.Cucumber.Messages; -using TechTalk.SpecFlow.CommonModels; - -namespace TechTalk.SpecFlow.CucumberMessages -{ - public interface IPlatformFactory - { - TestCaseStarted.Types.Platform BuildFromSystemInformation(); - } -} diff --git a/TechTalk.SpecFlow/CucumberMessages/ISpecFlowVersionInformationProvider.cs b/TechTalk.SpecFlow/CucumberMessages/ISpecFlowVersionInformationProvider.cs deleted file mode 100644 index d9988c176..000000000 --- a/TechTalk.SpecFlow/CucumberMessages/ISpecFlowVersionInformationProvider.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace TechTalk.SpecFlow.CucumberMessages -{ - public interface ISpecFlowVersionInformationProvider - { - string GetAssemblyVersion(); - } -} diff --git a/TechTalk.SpecFlow/CucumberMessages/ISystemInformationProvider.cs b/TechTalk.SpecFlow/CucumberMessages/ISystemInformationProvider.cs deleted file mode 100644 index dd26bd4ba..000000000 --- a/TechTalk.SpecFlow/CucumberMessages/ISystemInformationProvider.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace TechTalk.SpecFlow.CucumberMessages -{ - public interface ISystemInformationProvider - { - string GetCpuArchitecture(); - string GetOperatingSystem(); - } -} diff --git a/TechTalk.SpecFlow/CucumberMessages/ITestAmbiguousMessageFactory.cs b/TechTalk.SpecFlow/CucumberMessages/ITestAmbiguousMessageFactory.cs deleted file mode 100644 index f9562154f..000000000 --- a/TechTalk.SpecFlow/CucumberMessages/ITestAmbiguousMessageFactory.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace TechTalk.SpecFlow.CucumberMessages -{ - public interface ITestAmbiguousMessageFactory - { - string BuildFromScenarioContext(ScenarioContext scenarioContext); - } -} diff --git a/TechTalk.SpecFlow/CucumberMessages/ITestErrorMessageFactory.cs b/TechTalk.SpecFlow/CucumberMessages/ITestErrorMessageFactory.cs deleted file mode 100644 index 8f7207db3..000000000 --- a/TechTalk.SpecFlow/CucumberMessages/ITestErrorMessageFactory.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace TechTalk.SpecFlow.CucumberMessages -{ - public interface ITestErrorMessageFactory - { - string BuildFromScenarioContext(ScenarioContext scenarioContext); - } -} diff --git a/TechTalk.SpecFlow/CucumberMessages/ITestResultFactory.cs b/TechTalk.SpecFlow/CucumberMessages/ITestResultFactory.cs deleted file mode 100644 index 718d36e54..000000000 --- a/TechTalk.SpecFlow/CucumberMessages/ITestResultFactory.cs +++ /dev/null @@ -1,10 +0,0 @@ -using Io.Cucumber.Messages; -using TechTalk.SpecFlow.CommonModels; - -namespace TechTalk.SpecFlow.CucumberMessages -{ - public interface ITestResultFactory - { - IResult BuildFromContext(ScenarioContext scenarioContext, FeatureContext featureContext); - } -} diff --git a/TechTalk.SpecFlow/CucumberMessages/ITestResultPartsFactory.cs b/TechTalk.SpecFlow/CucumberMessages/ITestResultPartsFactory.cs deleted file mode 100644 index b55bdd5c0..000000000 --- a/TechTalk.SpecFlow/CucumberMessages/ITestResultPartsFactory.cs +++ /dev/null @@ -1,15 +0,0 @@ -using Io.Cucumber.Messages; -using TechTalk.SpecFlow.CommonModels; - -namespace TechTalk.SpecFlow.CucumberMessages -{ - public interface ITestResultPartsFactory - { - IResult BuildPassedResult(ulong durationInNanoseconds); - IResult BuildFailedResult(ulong durationInNanoseconds, ScenarioContext scenarioContext); - IResult BuildAmbiguousResult(ulong durationInNanoseconds, ScenarioContext scenarioContext); - IResult BuildPendingResult(ulong durationInNanoseconds, ScenarioContext scenarioContext); - IResult BuildSkippedResult(ulong durationInNanoseconds); - IResult BuildUndefinedResult(ulong durationInNanoseconds, ScenarioContext scenarioContext, FeatureContext featureContext); - } -} \ No newline at end of file diff --git a/TechTalk.SpecFlow/CucumberMessages/ITestRunResultCollector.cs b/TechTalk.SpecFlow/CucumberMessages/ITestRunResultCollector.cs deleted file mode 100644 index 8785b125b..000000000 --- a/TechTalk.SpecFlow/CucumberMessages/ITestRunResultCollector.cs +++ /dev/null @@ -1,14 +0,0 @@ -using Io.Cucumber.Messages; -using TechTalk.SpecFlow.CommonModels; - -namespace TechTalk.SpecFlow.CucumberMessages -{ - public interface ITestRunResultCollector - { - void StartCollecting(); - - void CollectTestResultForScenario(ScenarioInfo scenarioInfo, TestResult testResult); - - IResult GetCurrentResult(); - } -} diff --git a/TechTalk.SpecFlow/CucumberMessages/ITestRunResultSuccessCalculator.cs b/TechTalk.SpecFlow/CucumberMessages/ITestRunResultSuccessCalculator.cs deleted file mode 100644 index 0fc4c3b40..000000000 --- a/TechTalk.SpecFlow/CucumberMessages/ITestRunResultSuccessCalculator.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace TechTalk.SpecFlow.CucumberMessages -{ - public interface ITestRunResultSuccessCalculator - { - bool IsSuccess(TestRunResult testRunResult); - } -} diff --git a/TechTalk.SpecFlow/CucumberMessages/NonStrictTestRunResultSuccessCalculator.cs b/TechTalk.SpecFlow/CucumberMessages/NonStrictTestRunResultSuccessCalculator.cs deleted file mode 100644 index 08259a721..000000000 --- a/TechTalk.SpecFlow/CucumberMessages/NonStrictTestRunResultSuccessCalculator.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace TechTalk.SpecFlow.CucumberMessages -{ - public class NonStrictTestRunResultSuccessCalculator : ITestRunResultSuccessCalculator - { - public bool IsSuccess(TestRunResult testRunResult) - { - return testRunResult.Failed == 0 - && testRunResult.Ambiguous == 0; - } - } -} diff --git a/TechTalk.SpecFlow/CucumberMessages/PickleIdGenerator.cs b/TechTalk.SpecFlow/CucumberMessages/PickleIdGenerator.cs deleted file mode 100644 index 1d8f429ef..000000000 --- a/TechTalk.SpecFlow/CucumberMessages/PickleIdGenerator.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; - -namespace TechTalk.SpecFlow.CucumberMessages -{ - public class PickleIdGenerator : IPickleIdGenerator - { - public Guid GeneratePickleId() - { - return Guid.NewGuid(); - } - } -} diff --git a/TechTalk.SpecFlow/CucumberMessages/PickleIdStore.cs b/TechTalk.SpecFlow/CucumberMessages/PickleIdStore.cs deleted file mode 100644 index 33def04b2..000000000 --- a/TechTalk.SpecFlow/CucumberMessages/PickleIdStore.cs +++ /dev/null @@ -1,51 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace TechTalk.SpecFlow.CucumberMessages -{ - public class PickleIdStore : IPickleIdStore - { - private readonly IPickleIdGenerator _pickleIdGenerator; - private readonly IPickleIdStoreDictionaryFactory _pickleIdStoreDictionaryFactory; - private readonly object _initializationLock = new object(); - private IDictionary _scenarioInfoMappings; - - public PickleIdStore(IPickleIdGenerator pickleIdGenerator, IPickleIdStoreDictionaryFactory pickleIdStoreDictionaryFactory) - { - _pickleIdGenerator = pickleIdGenerator; - _pickleIdStoreDictionaryFactory = pickleIdStoreDictionaryFactory; - } - - public Guid GetPickleIdForScenario(ScenarioInfo scenarioInfo) - { - EnsureIsInitialized(); - - if (_scenarioInfoMappings.ContainsKey(scenarioInfo)) - { - return _scenarioInfoMappings[scenarioInfo]; - } - - var pickleId = _pickleIdGenerator.GeneratePickleId(); - _scenarioInfoMappings.Add(scenarioInfo, pickleId); - return pickleId; - } - - public void EnsureIsInitialized() - { - if (_scenarioInfoMappings != null) - { - return; - } - - lock (_initializationLock) - { - if (_scenarioInfoMappings != null) - { - return; - } - - _scenarioInfoMappings = _pickleIdStoreDictionaryFactory.BuildDictionary(); - } - } - } -} diff --git a/TechTalk.SpecFlow/CucumberMessages/PickleIdStoreDictionaryFactory.cs b/TechTalk.SpecFlow/CucumberMessages/PickleIdStoreDictionaryFactory.cs deleted file mode 100644 index 37fdfbd32..000000000 --- a/TechTalk.SpecFlow/CucumberMessages/PickleIdStoreDictionaryFactory.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System; -using System.Collections.Concurrent; -using System.Collections.Generic; - -namespace TechTalk.SpecFlow.CucumberMessages -{ - public class PickleIdStoreDictionaryFactory : IPickleIdStoreDictionaryFactory - { - public IDictionary BuildDictionary() - { - return new ConcurrentDictionary(); - } - } -} diff --git a/TechTalk.SpecFlow/CucumberMessages/PlatformFactory.cs b/TechTalk.SpecFlow/CucumberMessages/PlatformFactory.cs deleted file mode 100644 index 5eada8ff4..000000000 --- a/TechTalk.SpecFlow/CucumberMessages/PlatformFactory.cs +++ /dev/null @@ -1,30 +0,0 @@ -using Io.Cucumber.Messages; -using TechTalk.SpecFlow.CommonModels; - -namespace TechTalk.SpecFlow.CucumberMessages -{ - public class PlatformFactory : IPlatformFactory - { - private readonly ISystemInformationProvider _systemInformationProvider; - private readonly ISpecFlowVersionInformationProvider _specFlowVersionInformationProvider; - - public PlatformFactory(ISystemInformationProvider systemInformationProvider, ISpecFlowVersionInformationProvider specFlowVersionInformationProvider) - { - _systemInformationProvider = systemInformationProvider; - _specFlowVersionInformationProvider = specFlowVersionInformationProvider; - } - - public TestCaseStarted.Types.Platform BuildFromSystemInformation() - { - var platform = new TestCaseStarted.Types.Platform - { - Cpu = _systemInformationProvider.GetCpuArchitecture(), - Os = _systemInformationProvider.GetOperatingSystem(), - Implementation = "SpecFlow", - Version = _specFlowVersionInformationProvider.GetAssemblyVersion() - }; - - return platform; - } - } -} diff --git a/TechTalk.SpecFlow/CucumberMessages/SinkProvider.cs b/TechTalk.SpecFlow/CucumberMessages/SinkProvider.cs deleted file mode 100644 index 4af6d611f..000000000 --- a/TechTalk.SpecFlow/CucumberMessages/SinkProvider.cs +++ /dev/null @@ -1,60 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using TechTalk.SpecFlow.Configuration; -using TechTalk.SpecFlow.CucumberMessages.Sinks; -using TechTalk.SpecFlow.FileAccess; - -namespace TechTalk.SpecFlow.CucumberMessages -{ - public interface ISinkProvider - { - List GetMessageSinksFromConfiguration(); - } - - public class SinkProvider : ISinkProvider - { - private readonly SpecFlowConfiguration _specFlowConfiguration; - private readonly IBinaryFileAccessor _binaryFileAccessor; - private readonly IProtobufFileNameResolver _protobufFileNameResolver; - - public SinkProvider(SpecFlowConfiguration specFlowConfiguration, IBinaryFileAccessor binaryFileAccessor, IProtobufFileNameResolver protobufFileNameResolver) - { - _specFlowConfiguration = specFlowConfiguration; - _binaryFileAccessor = binaryFileAccessor; - _protobufFileNameResolver = protobufFileNameResolver; - } - - public List GetMessageSinksFromConfiguration() - { - if (_specFlowConfiguration?.CucumberMessagesConfiguration?.Enabled != true) - { - return new List(); - } - - if (_specFlowConfiguration?.CucumberMessagesConfiguration?.Sinks?.Any() != true) - { - var protobufFileSinkConfiguration = new ProtobufFileSinkConfiguration("cucumbermessages/messages"); - return new List() {new ProtobufFileSink(new ProtobufFileSinkOutput(_binaryFileAccessor, protobufFileSinkConfiguration, _protobufFileNameResolver), protobufFileSinkConfiguration)}; - } - - - var messageSinksFromConfiguration = new List(); - foreach (var cucumberMessagesSink in _specFlowConfiguration.CucumberMessagesConfiguration.Sinks) - { - switch (cucumberMessagesSink.Type.ToLower()) - { - case "file": - var protobufFileSinkConfiguration = new ProtobufFileSinkConfiguration(cucumberMessagesSink.Path); - messageSinksFromConfiguration.Add(new ProtobufFileSink(new ProtobufFileSinkOutput(_binaryFileAccessor, protobufFileSinkConfiguration, _protobufFileNameResolver), protobufFileSinkConfiguration)); - break; - default: - throw new NotImplementedException($"The sink type {cucumberMessagesSink.Type}"); - } - } - - - return messageSinksFromConfiguration; - } - } -} \ No newline at end of file diff --git a/TechTalk.SpecFlow/CucumberMessages/Sinks/IProtobufFileNameResolver.cs b/TechTalk.SpecFlow/CucumberMessages/Sinks/IProtobufFileNameResolver.cs deleted file mode 100644 index ae39a72ad..000000000 --- a/TechTalk.SpecFlow/CucumberMessages/Sinks/IProtobufFileNameResolver.cs +++ /dev/null @@ -1,9 +0,0 @@ -using TechTalk.SpecFlow.CommonModels; - -namespace TechTalk.SpecFlow.CucumberMessages.Sinks -{ - public interface IProtobufFileNameResolver - { - IResult Resolve(string targetPath); - } -} diff --git a/TechTalk.SpecFlow/CucumberMessages/Sinks/IProtobufFileSinkOutput.cs b/TechTalk.SpecFlow/CucumberMessages/Sinks/IProtobufFileSinkOutput.cs deleted file mode 100644 index 108748c2e..000000000 --- a/TechTalk.SpecFlow/CucumberMessages/Sinks/IProtobufFileSinkOutput.cs +++ /dev/null @@ -1,11 +0,0 @@ -using Google.Protobuf; -using Io.Cucumber.Messages; -using TechTalk.SpecFlow.CommonModels; - -namespace TechTalk.SpecFlow.CucumberMessages.Sinks -{ - public interface IProtobufFileSinkOutput - { - IResult WriteMessage(Envelope message); - } -} diff --git a/TechTalk.SpecFlow/CucumberMessages/Sinks/ProtobufFileNameResolver.cs b/TechTalk.SpecFlow/CucumberMessages/Sinks/ProtobufFileNameResolver.cs deleted file mode 100644 index a19b3359c..000000000 --- a/TechTalk.SpecFlow/CucumberMessages/Sinks/ProtobufFileNameResolver.cs +++ /dev/null @@ -1,39 +0,0 @@ -using System.IO; -using TechTalk.SpecFlow.CommonModels; -using TechTalk.SpecFlow.EnvironmentAccess; -using TechTalk.SpecFlow.TestFramework; - -namespace TechTalk.SpecFlow.CucumberMessages.Sinks -{ - public class ProtobufFileNameResolver : IProtobufFileNameResolver - { - private readonly ITestRunContext _testRunContext; - private readonly IEnvironmentWrapper _environmentWrapper; - - public ProtobufFileNameResolver(ITestRunContext testRunContext, IEnvironmentWrapper environmentWrapper) - { - _testRunContext = testRunContext; - _environmentWrapper = environmentWrapper; - } - - public IResult Resolve(string targetPath) - { - var resolveEnvironmentVariablesResult = _environmentWrapper.ResolveEnvironmentVariables(targetPath); - switch (resolveEnvironmentVariablesResult) - { - case ISuccess success when Path.IsPathRooted(success.Result): - return Result.Success(success.Result); - - case ISuccess success: - string combinedPath = Path.Combine(_testRunContext.GetTestDirectory(), success.Result); - return Result.Success(combinedPath); - - case IFailure failure: - return Result.Failure($"Failed resolving environment variables from string '{targetPath}'", failure); - - default: - return Result.Failure($"Failed resolving environment variables from string '{targetPath}'"); - } - } - } -} diff --git a/TechTalk.SpecFlow/CucumberMessages/Sinks/ProtobufFileSink.cs b/TechTalk.SpecFlow/CucumberMessages/Sinks/ProtobufFileSink.cs deleted file mode 100644 index 1fa095838..000000000 --- a/TechTalk.SpecFlow/CucumberMessages/Sinks/ProtobufFileSink.cs +++ /dev/null @@ -1,47 +0,0 @@ -using System; -using System.IO; -using System.Threading; -using Io.Cucumber.Messages; -using TechTalk.SpecFlow.CommonModels; - -namespace TechTalk.SpecFlow.CucumberMessages.Sinks -{ - public class ProtobufFileSink : ICucumberMessageSink - { - private readonly IProtobufFileSinkOutput _protobufFileSinkOutput; - private readonly ProtobufFileSinkConfiguration _protobufFileSinkConfiguration; - - public ProtobufFileSink(IProtobufFileSinkOutput protobufFileSinkOutput, ProtobufFileSinkConfiguration protobufFileSinkConfiguration) - { - _protobufFileSinkOutput = protobufFileSinkOutput; - _protobufFileSinkConfiguration = protobufFileSinkConfiguration; - } - - public void SendMessage(Envelope message) - { - string absoluteTargetFilePath = Path.GetFullPath(_protobufFileSinkConfiguration.TargetFilePath) - .Replace('\\', '_') - .Replace('/', '_') - .Replace(':', '_'); - using (var mutex = new Mutex(false, $@"Global\SpecFlowTestExecution_{absoluteTargetFilePath}")) - { - mutex.WaitOne(); - - try - { - var result = _protobufFileSinkOutput.WriteMessage(message); - switch (result) - { - case ExceptionFailure exceptionFailure: throw exceptionFailure.Exception; - case Failure failure: throw new InvalidOperationException($"Could not write to file {_protobufFileSinkConfiguration.TargetFilePath}. {failure.Description}"); - case IFailure _: throw new InvalidOperationException($"Could not write to file {_protobufFileSinkConfiguration.TargetFilePath}."); - } - } - finally - { - mutex.ReleaseMutex(); - } - } - } - } -} diff --git a/TechTalk.SpecFlow/CucumberMessages/Sinks/ProtobufFileSinkConfiguration.cs b/TechTalk.SpecFlow/CucumberMessages/Sinks/ProtobufFileSinkConfiguration.cs deleted file mode 100644 index 4244d7444..000000000 --- a/TechTalk.SpecFlow/CucumberMessages/Sinks/ProtobufFileSinkConfiguration.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace TechTalk.SpecFlow.CucumberMessages.Sinks -{ - public class ProtobufFileSinkConfiguration - { - public ProtobufFileSinkConfiguration(string targetFilePath) - { - TargetFilePath = targetFilePath; - } - - public string TargetFilePath { get; } - } -} diff --git a/TechTalk.SpecFlow/CucumberMessages/Sinks/ProtobufFileSinkOutput.cs b/TechTalk.SpecFlow/CucumberMessages/Sinks/ProtobufFileSinkOutput.cs deleted file mode 100644 index f2474cfc0..000000000 --- a/TechTalk.SpecFlow/CucumberMessages/Sinks/ProtobufFileSinkOutput.cs +++ /dev/null @@ -1,61 +0,0 @@ -using System; -using System.IO; -using Google.Protobuf; -using Io.Cucumber.Messages; -using TechTalk.SpecFlow.CommonModels; -using TechTalk.SpecFlow.FileAccess; - -namespace TechTalk.SpecFlow.CucumberMessages.Sinks -{ - public class ProtobufFileSinkOutput : IProtobufFileSinkOutput - { - private readonly IBinaryFileAccessor _binaryFileAccessor; - private readonly ProtobufFileSinkConfiguration _protobufFileSinkConfiguration; - private readonly IProtobufFileNameResolver _protobufFileNameResolver; - - public ProtobufFileSinkOutput(IBinaryFileAccessor binaryFileAccessor, ProtobufFileSinkConfiguration protobufFileSinkConfiguration, IProtobufFileNameResolver protobufFileNameResolver) - { - _binaryFileAccessor = binaryFileAccessor; - _protobufFileSinkConfiguration = protobufFileSinkConfiguration; - _protobufFileNameResolver = protobufFileNameResolver; - } - - public IResult WriteMessage(Envelope message) - { - var resolveTargetFilePathResult = _protobufFileNameResolver.Resolve(_protobufFileSinkConfiguration.TargetFilePath); - if (!(resolveTargetFilePathResult is ISuccess resolveTargetFilePathSuccess)) - { - switch (resolveTargetFilePathResult) - { - case IFailure innerFailure: return Result.Failure("Stream could not be opened.", innerFailure); - default: return Result.Failure($"Stream could not be opened. File name '{_protobufFileSinkConfiguration.TargetFilePath}' could not be resolved."); - } - } - - var streamResult = _binaryFileAccessor.OpenAppendOrCreateFile(resolveTargetFilePathSuccess.Result); - switch (streamResult) - { - case IFailure failure: return Result.Failure("Stream could not be opened", failure); - case ISuccess success: return WriteMessageToStream(success.Result, message); - default: throw new InvalidOperationException($"The result from {nameof(BinaryFileAccessor.OpenAppendOrCreateFile)} must either implement {nameof(IFailure)} or {nameof(ISuccess)}"); - } - } - - private IResult WriteMessageToStream(Stream target, Envelope message) - { - try - { - using (target) - { - message.WriteDelimitedTo(target); - target.Flush(); - return Result.Success(); - } - } - catch (Exception e) - { - return Result.Failure(e); - } - } - } -} diff --git a/TechTalk.SpecFlow/CucumberMessages/SpecFlowVersionInformationProvider.cs b/TechTalk.SpecFlow/CucumberMessages/SpecFlowVersionInformationProvider.cs deleted file mode 100644 index ae2ddb9e1..000000000 --- a/TechTalk.SpecFlow/CucumberMessages/SpecFlowVersionInformationProvider.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace TechTalk.SpecFlow.CucumberMessages -{ - public class SpecFlowVersionInformationProvider : ISpecFlowVersionInformationProvider - { - public string GetAssemblyVersion() - { - var version = typeof(SpecFlowVersionInformationProvider).Assembly.GetName().Version; - return $"{version.Major}.{version.Minor}"; - } - } -} diff --git a/TechTalk.SpecFlow/CucumberMessages/StrictTestRunResultSuccessCalculator.cs b/TechTalk.SpecFlow/CucumberMessages/StrictTestRunResultSuccessCalculator.cs deleted file mode 100644 index 3586965ae..000000000 --- a/TechTalk.SpecFlow/CucumberMessages/StrictTestRunResultSuccessCalculator.cs +++ /dev/null @@ -1,13 +0,0 @@ -namespace TechTalk.SpecFlow.CucumberMessages -{ - public class StrictTestRunResultSuccessCalculator : ITestRunResultSuccessCalculator - { - public bool IsSuccess(TestRunResult testRunResult) - { - return testRunResult.Failed == 0 - && testRunResult.Skipped == 0 - && testRunResult.Ambiguous == 0 - && testRunResult.Undefined == 0; - } - } -} diff --git a/TechTalk.SpecFlow/CucumberMessages/SystemInformationProvider.cs b/TechTalk.SpecFlow/CucumberMessages/SystemInformationProvider.cs deleted file mode 100644 index 4af4a889c..000000000 --- a/TechTalk.SpecFlow/CucumberMessages/SystemInformationProvider.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System; - -#if NETSTANDARD -using System.Runtime.InteropServices; -#endif - -namespace TechTalk.SpecFlow.CucumberMessages -{ - public class SystemInformationProvider : ISystemInformationProvider - { -#if NETSTANDARD - public string GetCpuArchitecture() => RuntimeInformation.OSArchitecture.ToString(); - public string GetOperatingSystem() => RuntimeInformation.OSDescription; -#else - public string GetCpuArchitecture() => Environment.Is64BitOperatingSystem ? "x86" : "x64"; - public string GetOperatingSystem() => "Windows"; -#endif - } -} diff --git a/TechTalk.SpecFlow/CucumberMessages/TestAmbiguousMessageFactory.cs b/TechTalk.SpecFlow/CucumberMessages/TestAmbiguousMessageFactory.cs deleted file mode 100644 index 73d4da605..000000000 --- a/TechTalk.SpecFlow/CucumberMessages/TestAmbiguousMessageFactory.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace TechTalk.SpecFlow.CucumberMessages -{ - public class TestAmbiguousMessageFactory : ITestAmbiguousMessageFactory - { - public string BuildFromScenarioContext(ScenarioContext scenarioContext) - { - return scenarioContext.TestError?.ToString() ?? "Duplicate step binding found"; - } - } -} diff --git a/TechTalk.SpecFlow/CucumberMessages/TestErrorMessageFactory.cs b/TechTalk.SpecFlow/CucumberMessages/TestErrorMessageFactory.cs deleted file mode 100644 index a409fc6b4..000000000 --- a/TechTalk.SpecFlow/CucumberMessages/TestErrorMessageFactory.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; - -namespace TechTalk.SpecFlow.CucumberMessages -{ - public class TestErrorMessageFactory : ITestErrorMessageFactory - { - public string BuildFromScenarioContext(ScenarioContext scenarioContext) - { - return scenarioContext.TestError?.ToString() ?? "Test failed with an unknown error"; - } - } -} diff --git a/TechTalk.SpecFlow/CucumberMessages/TestResultFactory.cs b/TechTalk.SpecFlow/CucumberMessages/TestResultFactory.cs deleted file mode 100644 index e430abfea..000000000 --- a/TechTalk.SpecFlow/CucumberMessages/TestResultFactory.cs +++ /dev/null @@ -1,42 +0,0 @@ -using System; -using Io.Cucumber.Messages; -using TechTalk.SpecFlow.CommonModels; - -namespace TechTalk.SpecFlow.CucumberMessages -{ - public class TestResultFactory : ITestResultFactory - { - private readonly ITestResultPartsFactory _testResultPartsFactory; - - public TestResultFactory(ITestResultPartsFactory testResultPartsFactory) - { - _testResultPartsFactory = testResultPartsFactory; - } - - internal ulong ConvertTicksToPositiveNanoseconds(long ticks) - { - ulong ticksOrZero = (ulong)Math.Min(ticks, 0); - return ticksOrZero * 100; - } - - public IResult BuildFromContext(ScenarioContext scenarioContext, FeatureContext featureContext) - { - if (scenarioContext is null) - { - return Result.Failure(new ArgumentNullException(nameof(scenarioContext))); - } - - ulong nanoseconds = ConvertTicksToPositiveNanoseconds(scenarioContext.Stopwatch.Elapsed.Ticks); - switch (scenarioContext.ScenarioExecutionStatus) - { - case ScenarioExecutionStatus.OK: return _testResultPartsFactory.BuildPassedResult(nanoseconds); - case ScenarioExecutionStatus.TestError: return _testResultPartsFactory.BuildFailedResult(nanoseconds, scenarioContext); - case ScenarioExecutionStatus.StepDefinitionPending: return _testResultPartsFactory.BuildPendingResult(nanoseconds, scenarioContext); - case ScenarioExecutionStatus.BindingError: return _testResultPartsFactory.BuildAmbiguousResult(nanoseconds, scenarioContext); - case ScenarioExecutionStatus.UndefinedStep: return _testResultPartsFactory.BuildUndefinedResult(nanoseconds, scenarioContext, featureContext); - case ScenarioExecutionStatus.Skipped: return _testResultPartsFactory.BuildSkippedResult(nanoseconds); - default: return Result.Failure($"Status '{scenarioContext.ScenarioExecutionStatus}' is unknown or not supported."); - } - } - } -} \ No newline at end of file diff --git a/TechTalk.SpecFlow/CucumberMessages/TestResultPartsFactory.cs b/TechTalk.SpecFlow/CucumberMessages/TestResultPartsFactory.cs deleted file mode 100644 index 75febc9b2..000000000 --- a/TechTalk.SpecFlow/CucumberMessages/TestResultPartsFactory.cs +++ /dev/null @@ -1,84 +0,0 @@ -using Io.Cucumber.Messages; -using TechTalk.SpecFlow.CommonModels; -using static Io.Cucumber.Messages.TestResult.Types; - -namespace TechTalk.SpecFlow.CucumberMessages -{ - public class TestResultPartsFactory : ITestResultPartsFactory - { - private readonly ITestAmbiguousMessageFactory _testAmbiguousMessageFactory; - private readonly ITestErrorMessageFactory _testErrorMessageFactory; - private readonly ITestPendingMessageFactory _testPendingMessageFactory; - private readonly ITestUndefinedMessageFactory _testUndefinedMessageFactory; - - public TestResultPartsFactory(ITestErrorMessageFactory testErrorMessageFactory, ITestPendingMessageFactory testPendingMessageFactory, ITestAmbiguousMessageFactory testAmbiguousMessageFactory, - ITestUndefinedMessageFactory testUndefinedMessageFactory) - { - _testErrorMessageFactory = testErrorMessageFactory; - _testPendingMessageFactory = testPendingMessageFactory; - _testAmbiguousMessageFactory = testAmbiguousMessageFactory; - _testUndefinedMessageFactory = testUndefinedMessageFactory; - } - - - public IResult BuildPassedResult(ulong durationInNanoseconds) - { - return BuildTestResult(durationInNanoseconds, Status.Passed, ""); - } - - public IResult BuildFailedResult(ulong durationInNanoseconds, ScenarioContext scenarioContext) - { - return BuildTestResult(durationInNanoseconds, Status.Failed, _testErrorMessageFactory.BuildFromScenarioContext(scenarioContext)); - } - - public IResult BuildAmbiguousResult(ulong durationInNanoseconds, ScenarioContext scenarioContext) - { - return BuildTestResult(durationInNanoseconds, Status.Ambiguous, _testAmbiguousMessageFactory.BuildFromScenarioContext(scenarioContext)); - } - - public IResult BuildPendingResult(ulong durationInNanoseconds, ScenarioContext scenarioContext) - { - return BuildTestResult(durationInNanoseconds, Status.Pending, _testPendingMessageFactory.BuildFromScenarioContext(scenarioContext)); - } - - public IResult BuildSkippedResult(ulong durationInNanoseconds) - { - return BuildTestResult(durationInNanoseconds, Status.Skipped, ""); - } - - public IResult BuildUndefinedResult(ulong durationInNanoseconds, ScenarioContext scenarioContext, FeatureContext featureContext) - { - return BuildTestResult(durationInNanoseconds, Status.Undefined, _testUndefinedMessageFactory.BuildFromContext(scenarioContext, featureContext)); - } - - internal IResult BuildTestResult(ulong durationInNanoseconds, Status status, string message) - { - var testResult = new TestResult - { - Duration = durationInNanoseconds.ToCucumberMessagesDuration(), - Status = status, - Message = message ?? "" - }; - - return Result.Success(testResult); - } - } - - - static class ULongExtensions - { - public static Duration ToCucumberMessagesDuration(this ulong durationInNanoseconds) - { - ulong seconds = durationInNanoseconds / 1_000_000_000; - ulong nanos = durationInNanoseconds - (seconds * 1_000_000_000); - - - return new Duration() - { - Seconds = (long)seconds, - Nanos = (int)nanos - }; - - } - } -} \ No newline at end of file diff --git a/TechTalk.SpecFlow/CucumberMessages/TestRunResult.cs b/TechTalk.SpecFlow/CucumberMessages/TestRunResult.cs deleted file mode 100644 index f8c7482da..000000000 --- a/TechTalk.SpecFlow/CucumberMessages/TestRunResult.cs +++ /dev/null @@ -1,27 +0,0 @@ -namespace TechTalk.SpecFlow.CucumberMessages -{ - public class TestRunResult - { - public TestRunResult(int total, int passed, int failed, int skipped, int ambiguous, int undefined) - { - Total = total; - Passed = passed; - Failed = failed; - Skipped = skipped; - Ambiguous = ambiguous; - Undefined = undefined; - } - - public int Total { get; } - - public int Passed { get; } - - public int Failed { get; } - - public int Skipped { get; } - - public int Ambiguous { get; } - - public int Undefined { get; } - } -} diff --git a/TechTalk.SpecFlow/CucumberMessages/TestRunResultCollector.cs b/TechTalk.SpecFlow/CucumberMessages/TestRunResultCollector.cs deleted file mode 100644 index 685f0d6d4..000000000 --- a/TechTalk.SpecFlow/CucumberMessages/TestRunResultCollector.cs +++ /dev/null @@ -1,72 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using Io.Cucumber.Messages; -using TechTalk.SpecFlow.CommonModels; - -namespace TechTalk.SpecFlow.CucumberMessages -{ - public class TestRunResultCollector : ITestRunResultCollector - { - private readonly IDictionary _collectedResults = new Dictionary(); - public bool IsStarted { get; private set; } - - private readonly object _lock = new object(); - - public void StartCollecting() - { - if (IsStarted) - { - return; - } - - IsStarted = true; - } - - public void CollectTestResultForScenario(ScenarioInfo scenarioInfo, TestResult testResult) - { - if (!IsStarted) - { - throw new InvalidOperationException("Result collection has not been started."); - } - - - lock (_lock) - { - _collectedResults.Add(scenarioInfo, testResult); - } - } - - public IResult GetCurrentResult() - { - if (!IsStarted) - { - return Result.Failure("Result collection has not been started"); - } - - - IGrouping[] groups; - lock (_lock) - { - groups = _collectedResults.GroupBy(kv => kv.Value.Status, kv => (kv.Key, kv.Value)) - .ToArray(); - } - - var passedCount = groups.SingleOrDefault(g => g.Key == TestResult.Types.Status.Passed)?.Count() ?? 0; - var failedCount = groups.SingleOrDefault(g => g.Key == TestResult.Types.Status.Failed)?.Count() ?? 0; - var skippedCount = groups.SingleOrDefault(g => g.Key == TestResult.Types.Status.Skipped)?.Count() ?? 0; - var ambiguousCount = groups.SingleOrDefault(g => g.Key == TestResult.Types.Status.Ambiguous)?.Count() ?? 0; - var undefinedCount = groups.SingleOrDefault(g => g.Key == TestResult.Types.Status.Undefined)?.Count() ?? 0; - - var testRunResult = new TestRunResult( - _collectedResults.Count, - passedCount, - failedCount, - skippedCount, - ambiguousCount, - undefinedCount); - - return Result.Success(testRunResult); - } - } -} \ No newline at end of file diff --git a/TechTalk.SpecFlow/DateTimeExtensions.cs b/TechTalk.SpecFlow/DateTimeExtensions.cs index cb4adf22a..6a2186197 100644 --- a/TechTalk.SpecFlow/DateTimeExtensions.cs +++ b/TechTalk.SpecFlow/DateTimeExtensions.cs @@ -1,5 +1,4 @@ using System; -using Io.Cucumber.Messages; namespace TechTalk.SpecFlow { @@ -25,30 +24,7 @@ public static (long, int) ToUnixTimeStamp(this DateTime dateTime) } - public static Timestamp ToCucumberMessagesTimestamp(this DateTime dateTime) - { - var (seconds, nanos) = dateTime.ToUnixTimeStamp(); - - return new Timestamp() - { - Seconds = seconds, - Nanos = nanos - }; - } - - - public static Duration ToCucumberMessagesDuration(this TimeSpan timeSpan) - { - var timeSpanWithoutTicks = new TimeSpan(timeSpan.Days, timeSpan.Hours, timeSpan.Minutes, timeSpan.Seconds); - - var ticksDifference = timeSpan.Ticks - timeSpanWithoutTicks.Ticks; - - return new Duration() - { - Seconds = (int)timeSpan.TotalSeconds, - Nanos = (int)ticksDifference*100 - }; - } + } } \ No newline at end of file diff --git a/TechTalk.SpecFlow/Infrastructure/DefaultDependencyProvider.cs b/TechTalk.SpecFlow/Infrastructure/DefaultDependencyProvider.cs index af3c20fdb..0fe327270 100644 --- a/TechTalk.SpecFlow/Infrastructure/DefaultDependencyProvider.cs +++ b/TechTalk.SpecFlow/Infrastructure/DefaultDependencyProvider.cs @@ -6,8 +6,6 @@ using TechTalk.SpecFlow.Bindings; using TechTalk.SpecFlow.Bindings.Discovery; using TechTalk.SpecFlow.Configuration; -using TechTalk.SpecFlow.CucumberMessages; -using TechTalk.SpecFlow.CucumberMessages.Sinks; using TechTalk.SpecFlow.EnvironmentAccess; using TechTalk.SpecFlow.ErrorHandling; using TechTalk.SpecFlow.Events; @@ -62,32 +60,14 @@ public virtual void RegisterGlobalContainerDefaults(ObjectContainer container) container.RegisterTypeAs(); container.RegisterTypeAs(); - container.RegisterTypeAs(); container.RegisterTypeAs(); - container.RegisterTypeAs(); container.RegisterTypeAs(); - container.RegisterTypeAs(); - container.RegisterTypeAs(); - container.RegisterTypeAs(); container.RegisterTypeAs(); container.RegisterTypeAs(); container.RegisterTypeAs(); - container.RegisterTypeAs(); - container.RegisterTypeAs(); - container.RegisterTypeAs(); - container.RegisterTypeAs(); - container.RegisterTypeAs(); - container.RegisterTypeAs(); - container.RegisterTypeAs(); - container.RegisterTypeAs(); - container.RegisterTypeAs(); - container.RegisterTypeAs(); - container.RegisterTypeAs(); - - container.RegisterTypeAs(); - container.RegisterTypeAs(); + container.RegisterTypeAs(); container.RegisterTypeAs(); diff --git a/TechTalk.SpecFlow/CucumberMessages/ITestPendingMessageFactory.cs b/TechTalk.SpecFlow/Infrastructure/ITestPendingMessageFactory.cs similarity index 74% rename from TechTalk.SpecFlow/CucumberMessages/ITestPendingMessageFactory.cs rename to TechTalk.SpecFlow/Infrastructure/ITestPendingMessageFactory.cs index c8942301e..e2958b226 100644 --- a/TechTalk.SpecFlow/CucumberMessages/ITestPendingMessageFactory.cs +++ b/TechTalk.SpecFlow/Infrastructure/ITestPendingMessageFactory.cs @@ -1,4 +1,4 @@ -namespace TechTalk.SpecFlow.CucumberMessages +namespace TechTalk.SpecFlow.Infrastructure { public interface ITestPendingMessageFactory { diff --git a/TechTalk.SpecFlow/CucumberMessages/ITestUndefinedMessageFactory.cs b/TechTalk.SpecFlow/Infrastructure/ITestUndefinedMessageFactory.cs similarity index 77% rename from TechTalk.SpecFlow/CucumberMessages/ITestUndefinedMessageFactory.cs rename to TechTalk.SpecFlow/Infrastructure/ITestUndefinedMessageFactory.cs index 643ee349d..f949c45db 100644 --- a/TechTalk.SpecFlow/CucumberMessages/ITestUndefinedMessageFactory.cs +++ b/TechTalk.SpecFlow/Infrastructure/ITestUndefinedMessageFactory.cs @@ -1,4 +1,4 @@ -namespace TechTalk.SpecFlow.CucumberMessages +namespace TechTalk.SpecFlow.Infrastructure { public interface ITestUndefinedMessageFactory { diff --git a/TechTalk.SpecFlow/Infrastructure/TestExecutionEngine.cs b/TechTalk.SpecFlow/Infrastructure/TestExecutionEngine.cs index 39c0396f5..4f3861026 100644 --- a/TechTalk.SpecFlow/Infrastructure/TestExecutionEngine.cs +++ b/TechTalk.SpecFlow/Infrastructure/TestExecutionEngine.cs @@ -1,17 +1,13 @@ using System; -using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.Linq; using BoDi; -using Io.Cucumber.Messages; using TechTalk.SpecFlow.Analytics; using TechTalk.SpecFlow.Bindings; using TechTalk.SpecFlow.Bindings.Reflection; -using TechTalk.SpecFlow.CommonModels; using TechTalk.SpecFlow.Compatibility; using TechTalk.SpecFlow.Configuration; -using TechTalk.SpecFlow.CucumberMessages; using TechTalk.SpecFlow.ErrorHandling; using TechTalk.SpecFlow.Events; using TechTalk.SpecFlow.Plugins; @@ -27,11 +23,6 @@ public class TestExecutionEngine : ITestExecutionEngine private readonly IContextManager _contextManager; private readonly IErrorProvider _errorProvider; private readonly IObsoleteStepHandler _obsoleteStepHandler; - private readonly ICucumberMessageSender _cucumberMessageSender; - private readonly ITestResultFactory _testResultFactory; - private readonly ITestPendingMessageFactory _testPendingMessageFactory; - private readonly ITestUndefinedMessageFactory _testUndefinedMessageFactory; - private readonly ITestRunResultCollector _testRunResultCollector; private readonly SpecFlowConfiguration _specFlowConfiguration; private readonly IStepArgumentTypeConverter _stepArgumentTypeConverter; private readonly IStepDefinitionMatchService _stepDefinitionMatchService; @@ -51,6 +42,8 @@ public class TestExecutionEngine : ITestExecutionEngine private bool _testRunnerEndExecuted = false; private object _testRunnerEndExecutedLock = new object(); private bool _testRunnerStartExecuted = false; + private ITestPendingMessageFactory _testPendingMessageFactory; + private ITestUndefinedMessageFactory _testUndefinedMessageFactory; public TestExecutionEngine( IStepFormatter stepFormatter, @@ -64,16 +57,13 @@ public TestExecutionEngine( IStepDefinitionMatchService stepDefinitionMatchService, IBindingInvoker bindingInvoker, IObsoleteStepHandler obsoleteStepHandler, - ICucumberMessageSender cucumberMessageSender, - ITestResultFactory testResultFactory, - ITestPendingMessageFactory testPendingMessageFactory, - ITestUndefinedMessageFactory testUndefinedMessageFactory, - ITestRunResultCollector testRunResultCollector, IAnalyticsEventProvider analyticsEventProvider, IAnalyticsTransmitter analyticsTransmitter, ITestRunnerManager testRunnerManager, IRuntimePluginTestExecutionLifecycleEventEmitter runtimePluginTestExecutionLifecycleEventEmitter, ITestThreadExecutionEventPublisher testThreadExecutionEventPublisher, + ITestPendingMessageFactory testPendingMessageFactory, + ITestUndefinedMessageFactory testUndefinedMessageFactory, ITestObjectResolver testObjectResolver = null, IObjectContainer testThreadContainer = null) //TODO: find a better way to access the container { @@ -90,16 +80,13 @@ public TestExecutionEngine( _testObjectResolver = testObjectResolver; TestThreadContainer = testThreadContainer; _obsoleteStepHandler = obsoleteStepHandler; - _cucumberMessageSender = cucumberMessageSender; - _testResultFactory = testResultFactory; - _testPendingMessageFactory = testPendingMessageFactory; - _testUndefinedMessageFactory = testUndefinedMessageFactory; - _testRunResultCollector = testRunResultCollector; _analyticsEventProvider = analyticsEventProvider; _analyticsTransmitter = analyticsTransmitter; _testRunnerManager = testRunnerManager; _runtimePluginTestExecutionLifecycleEventEmitter = runtimePluginTestExecutionLifecycleEventEmitter; _testThreadExecutionEventPublisher = testThreadExecutionEventPublisher; + _testPendingMessageFactory = testPendingMessageFactory; + _testUndefinedMessageFactory = testUndefinedMessageFactory; } public FeatureContext FeatureContext => _contextManager.FeatureContext; @@ -128,8 +115,6 @@ public virtual void OnTestRunStart() } _testRunnerStartExecuted = true; - _cucumberMessageSender.SendTestRunStarted(); - _testRunResultCollector.StartCollecting(); _testThreadExecutionEventPublisher.PublishEvent(new TestRunStartedEvent()); @@ -148,13 +133,6 @@ public virtual void OnTestRunEnd() _testRunnerEndExecuted = true; } - var testRunResultResult = _testRunResultCollector.GetCurrentResult(); - - if (testRunResultResult is ISuccess success) - { - _cucumberMessageSender.SendTestRunFinished(success.Result); - } - FireEvents(HookType.AfterTestRun); _testThreadExecutionEventPublisher.PublishEvent(new TestRunFinishedEvent()); @@ -211,7 +189,6 @@ public virtual void OnScenarioInitialize(ScenarioInfo scenarioInfo) public virtual void OnScenarioStart() { - _cucumberMessageSender.SendTestCaseStarted(_contextManager.ScenarioContext.ScenarioInfo); _testThreadExecutionEventPublisher.PublishEvent(new ScenarioStartedEvent(FeatureContext, ScenarioContext)); try @@ -239,19 +216,6 @@ public virtual void OnAfterLastStep() _testTracer.TraceDuration(duration, "Scenario: " + _contextManager.ScenarioContext.ScenarioInfo.Title); } - var testResultResult = _testResultFactory.BuildFromContext(_contextManager.ScenarioContext, _contextManager.FeatureContext); - switch (testResultResult) - { - case ISuccess success: - _cucumberMessageSender.SendTestCaseFinished(_contextManager.ScenarioContext.ScenarioInfo, success.Result); - _testRunResultCollector.CollectTestResultForScenario(_contextManager.ScenarioContext.ScenarioInfo, success.Result); - break; - - case IFailure failure: - _testTracer.TraceWarning(failure.ToString()); - break; - } - if (_contextManager.ScenarioContext.ScenarioExecutionStatus == ScenarioExecutionStatus.OK) { return; @@ -305,7 +269,6 @@ public virtual void OnScenarioEnd() public virtual void OnScenarioSkipped() { // after discussing the placement of message sending points, this placement causes far less effort than rewriting the whole logic - _cucumberMessageSender.SendTestCaseStarted(_contextManager.ScenarioContext.ScenarioInfo); _contextManager.ScenarioContext.ScenarioExecutionStatus = ScenarioExecutionStatus.Skipped; // in case of skipping a Scenario, the OnScenarioStart() is not called, so publish the event here diff --git a/TechTalk.SpecFlow/CucumberMessages/TestPendingMessageFactory.cs b/TechTalk.SpecFlow/Infrastructure/TestPendingMessageFactory.cs similarity index 93% rename from TechTalk.SpecFlow/CucumberMessages/TestPendingMessageFactory.cs rename to TechTalk.SpecFlow/Infrastructure/TestPendingMessageFactory.cs index 5ce9f9b34..fc1bc724b 100644 --- a/TechTalk.SpecFlow/CucumberMessages/TestPendingMessageFactory.cs +++ b/TechTalk.SpecFlow/Infrastructure/TestPendingMessageFactory.cs @@ -2,7 +2,7 @@ using System.Linq; using TechTalk.SpecFlow.ErrorHandling; -namespace TechTalk.SpecFlow.CucumberMessages +namespace TechTalk.SpecFlow.Infrastructure { public class TestPendingMessageFactory : ITestPendingMessageFactory { diff --git a/TechTalk.SpecFlow/CucumberMessages/TestUndefinedMessageFactory.cs b/TechTalk.SpecFlow/Infrastructure/TestUndefinedMessageFactory.cs similarity index 97% rename from TechTalk.SpecFlow/CucumberMessages/TestUndefinedMessageFactory.cs rename to TechTalk.SpecFlow/Infrastructure/TestUndefinedMessageFactory.cs index 3e56bbd0f..665c8fef9 100644 --- a/TechTalk.SpecFlow/CucumberMessages/TestUndefinedMessageFactory.cs +++ b/TechTalk.SpecFlow/Infrastructure/TestUndefinedMessageFactory.cs @@ -4,7 +4,7 @@ using TechTalk.SpecFlow.Configuration; using TechTalk.SpecFlow.ErrorHandling; -namespace TechTalk.SpecFlow.CucumberMessages +namespace TechTalk.SpecFlow.Infrastructure { public class TestUndefinedMessageFactory : ITestUndefinedMessageFactory { diff --git a/TechTalk.SpecFlow/SpecFlow.nuspec b/TechTalk.SpecFlow/SpecFlow.nuspec index 94a3fa9ac..13e77569e 100644 --- a/TechTalk.SpecFlow/SpecFlow.nuspec +++ b/TechTalk.SpecFlow/SpecFlow.nuspec @@ -19,7 +19,6 @@ - @@ -30,7 +29,6 @@ - diff --git a/TechTalk.SpecFlow/TechTalk.SpecFlow.csproj b/TechTalk.SpecFlow/TechTalk.SpecFlow.csproj index fad36bf74..d65784d8c 100644 --- a/TechTalk.SpecFlow/TechTalk.SpecFlow.csproj +++ b/TechTalk.SpecFlow/TechTalk.SpecFlow.csproj @@ -19,7 +19,6 @@ - all runtime; build; native; contentfiles; analyzers diff --git a/Tests/TechTalk.SpecFlow.RuntimeTests/Bindings/CultureInfoScopeTests.cs b/Tests/TechTalk.SpecFlow.RuntimeTests/Bindings/CultureInfoScopeTests.cs index 388dfe497..4bcf3d923 100644 --- a/Tests/TechTalk.SpecFlow.RuntimeTests/Bindings/CultureInfoScopeTests.cs +++ b/Tests/TechTalk.SpecFlow.RuntimeTests/Bindings/CultureInfoScopeTests.cs @@ -51,7 +51,7 @@ private static FeatureContext GetFeatureContext(CultureInfo cultureInfo) { return new FeatureContext(default, new FeatureInfo(cultureInfo, default, default, default), - new SpecFlowConfiguration(default, default, default, default, cultureInfo, default, default, default, default, default, default, default, default, default, default, default, default)); + new SpecFlowConfiguration(default, default, default, default, cultureInfo, default, default, default, default, default, default, default, default, default, default, default)); } } } diff --git a/Tests/TechTalk.SpecFlow.RuntimeTests/Configuration/AppConfigTests.cs b/Tests/TechTalk.SpecFlow.RuntimeTests/Configuration/AppConfigTests.cs index 8b3683f76..ceb1b7098 100644 --- a/Tests/TechTalk.SpecFlow.RuntimeTests/Configuration/AppConfigTests.cs +++ b/Tests/TechTalk.SpecFlow.RuntimeTests/Configuration/AppConfigTests.cs @@ -330,130 +330,5 @@ public void Check_StepAssemblies_TwoEntry() runtimeConfig.AdditionalStepAssemblies[0].Should().Be("testEntry1"); runtimeConfig.AdditionalStepAssemblies[1].Should().Be("testEntry2"); } - - - [Fact] - public void Check_CucumberMessages_NotConfigured_EnabledIsFalse() - { - string config = @" - "; - - var configSection = ConfigurationSectionHandler.CreateFromXml(config); - - var runtimeConfig = new AppConfigConfigurationLoader().LoadAppConfig(ConfigurationLoader.GetDefault(), configSection); - runtimeConfig.CucumberMessagesConfiguration.Enabled.Should().BeFalse(); - } - - - [Fact] - public void Check_CucumberMessages_EmptyTag_EnabledIsFalse() - { - string config = @" - - "; - - var configSection = ConfigurationSectionHandler.CreateFromXml(config); - - var runtimeConfig = new AppConfigConfigurationLoader().LoadAppConfig(ConfigurationLoader.GetDefault(), configSection); - runtimeConfig.CucumberMessagesConfiguration.Enabled.Should().BeFalse(); - } - - [Fact] - public void Check_CucumberMessages_Enabled_True() - { - string config = @" - - "; - - var configSection = ConfigurationSectionHandler.CreateFromXml(config); - - var runtimeConfig = new AppConfigConfigurationLoader().LoadAppConfig(ConfigurationLoader.GetDefault(), configSection); - runtimeConfig.CucumberMessagesConfiguration.Enabled.Should().BeTrue(); - } - - [Fact] - public void Check_CucumberMessages_Enabled_False() - { - string config = @" - - "; - - var configSection = ConfigurationSectionHandler.CreateFromXml(config); - - var runtimeConfig = new AppConfigConfigurationLoader().LoadAppConfig(ConfigurationLoader.GetDefault(), configSection); - runtimeConfig.CucumberMessagesConfiguration.Enabled.Should().BeFalse(); - } - - [Fact] - public void Check_CucumberMessages_Sinks_EmptyList() - { - string config = @" - - - - - "; - - var configSection = ConfigurationSectionHandler.CreateFromXml(config); - - var runtimeConfig = new AppConfigConfigurationLoader().LoadAppConfig(ConfigurationLoader.GetDefault(), configSection); - runtimeConfig.CucumberMessagesConfiguration.Sinks.Should().BeEmpty(); - } - - [Fact] - public void Check_CucumberMessages_Sinks_ListOneEntry() - { - string config = @" - - - - - - "; - - var configSection = ConfigurationSectionHandler.CreateFromXml(config); - - var runtimeConfig = new AppConfigConfigurationLoader().LoadAppConfig(ConfigurationLoader.GetDefault(), configSection); - runtimeConfig.CucumberMessagesConfiguration.Sinks.Count.Should().Be(1); - } - - [Fact] - public void Check_CucumberMessages_Sinks_ListMultipleEntry() - { - string config = @" - - - - - - - - "; - - var configSection = ConfigurationSectionHandler.CreateFromXml(config); - - var runtimeConfig = new AppConfigConfigurationLoader().LoadAppConfig(ConfigurationLoader.GetDefault(), configSection); - runtimeConfig.CucumberMessagesConfiguration.Sinks.Count.Should().Be(3); - } - - [Fact] - public void Check_CucumberMessages_Sinks_DataOfEntry() - { - string config = @" - - - - - - "; - - var configSection = ConfigurationSectionHandler.CreateFromXml(config); - - var runtimeConfig = new AppConfigConfigurationLoader().LoadAppConfig(ConfigurationLoader.GetDefault(), configSection); - var cucumberMessagesSink = runtimeConfig.CucumberMessagesConfiguration.Sinks.First(); - - cucumberMessagesSink.Type.Should().Be("file"); - cucumberMessagesSink.Path.Should().Be(@"C:\temp\testrun.cm"); - } } } diff --git a/Tests/TechTalk.SpecFlow.RuntimeTests/Configuration/JsonConfigTests.cs b/Tests/TechTalk.SpecFlow.RuntimeTests/Configuration/JsonConfigTests.cs index 4ca6e2df1..3c7f55c40 100644 --- a/Tests/TechTalk.SpecFlow.RuntimeTests/Configuration/JsonConfigTests.cs +++ b/Tests/TechTalk.SpecFlow.RuntimeTests/Configuration/JsonConfigTests.cs @@ -15,7 +15,8 @@ namespace TechTalk.SpecFlow.RuntimeTests.Configuration public class JsonConfigTests { [Theory] - [InlineData(@"{ + [InlineData( + @"{ ""language"": { ""feature"": ""en"", ""tool"": ""en"" @@ -35,16 +36,6 @@ public class JsonConfigTests ""traceTimings"": false, ""minTracedDuration"": ""0:0:0.1"", ""listener"": ""TechTalk.SpecFlow.Tracing.DefaultListener, TechTalk.SpecFlow"" - }, - ""cucumber-messages"": - { - ""enabled"": false, - ""sinks"": - [ - { ""type"": ""file"", ""path"": ""C:\temp\testrun.cm"" }, - { ""type"": ""file"", ""path"": ""testrun.cm"" }, - { ""type"": ""file"", ""path"": ""%temp%\testrun.cm"" } - ] } }")] @@ -366,135 +357,6 @@ public void Check_StepAssemblies_TwoEntry() runtimeConfig.AdditionalStepAssemblies[1].Should().Be("testEntry2"); } - - [Fact] - public void Check_CucumberMessages_NotConfigured_EnabledIsFalse() - { - string config = @"{ - }"; - - var runtimeConfig = new JsonConfigurationLoader().LoadJson(ConfigurationLoader.GetDefault(), config); - runtimeConfig.CucumberMessagesConfiguration.Enabled.Should().BeFalse(); - } - - - [Fact] - public void Check_CucumberMessages_EmptyTag_EnabledIsFalse() - { - string config = @"{ - ""cucumber-messages"": - { - } - }"; - - var runtimeConfig = new JsonConfigurationLoader().LoadJson(ConfigurationLoader.GetDefault(), config); - runtimeConfig.CucumberMessagesConfiguration.Enabled.Should().BeFalse(); - } - - [Fact] - public void Check_CucumberMessages_Enabled_True() - { - string config = @"{ - ""cucumber-messages"": - { - ""enabled"": true - } - }"; - - var runtimeConfig = new JsonConfigurationLoader().LoadJson(ConfigurationLoader.GetDefault(), config); - runtimeConfig.CucumberMessagesConfiguration.Enabled.Should().BeTrue(); - } - - [Fact] - public void Check_CucumberMessages_Enabled_False() - { - string config = @"{ - ""cucumber-messages"": - { - ""enabled"": false - } - }"; - - var runtimeConfig = new JsonConfigurationLoader().LoadJson(ConfigurationLoader.GetDefault(), config); - runtimeConfig.CucumberMessagesConfiguration.Enabled.Should().BeFalse(); - } - - [Fact] - public void Check_CucumberMessages_Sinks_EmptyList() - { - string config = @"{ - ""cucumber-messages"": - { - ""enabled"": false, - ""sinks"": - [ - ] - } - }"; - - var runtimeConfig = new JsonConfigurationLoader().LoadJson(ConfigurationLoader.GetDefault(), config); - runtimeConfig.CucumberMessagesConfiguration.Sinks.Should().BeEmpty(); - } - - [Fact] - public void Check_CucumberMessages_Sinks_ListOneEntry() - { - string config = @"{ - ""cucumber-messages"": - { - ""enabled"": false, - ""sinks"": - [ - { ""type"": ""file"", ""path"": ""C:\temp\testrun.cm"" } - ] - } - }"; - - var runtimeConfig = new JsonConfigurationLoader().LoadJson(ConfigurationLoader.GetDefault(), config); - runtimeConfig.CucumberMessagesConfiguration.Sinks.Count.Should().Be(1); - } - - [Fact] - public void Check_CucumberMessages_Sinks_ListMultipleEntry() - { - string config = @"{ - ""cucumber-messages"": - { - ""enabled"": false, - ""sinks"": - [ - { ""type"": ""file"", ""path"": ""C:\temp\testrun.cm"" }, - { ""type"": ""file"", ""path"": ""C:\temp\testrun.cm"" }, - { ""type"": ""file"", ""path"": ""C:\temp\testrun.cm"" } - ] - } - }"; - - var runtimeConfig = new JsonConfigurationLoader().LoadJson(ConfigurationLoader.GetDefault(), config); - runtimeConfig.CucumberMessagesConfiguration.Sinks.Count.Should().Be(3); - } - - [Fact] - public void Check_CucumberMessages_Sinks_DataOfEntry() - { - string config = @"{ - ""cucumber-messages"": - { - ""enabled"": false, - ""sinks"": - [ - { ""type"": ""file"", ""path"": ""C:\\temp\\testrun.cm"" } - ] - } - }"; - - var runtimeConfig = new JsonConfigurationLoader().LoadJson(ConfigurationLoader.GetDefault(), config); - var cucumberMessagesSink = runtimeConfig.CucumberMessagesConfiguration.Sinks.First(); - - cucumberMessagesSink.Type.Should().Be("file"); - cucumberMessagesSink.Path.Should().Be(@"C:\temp\testrun.cm"); - } - [Fact] public void Check_Generator_NonParallelizableMarkers_EmptyList() { @@ -614,5 +476,5 @@ private void AssertDefaultJsonSpecFlowConfiguration(SpecFlowConfiguration config config.AdditionalStepAssemblies.Should().NotBeNull(); config.AdditionalStepAssemblies.Should().BeEmpty(); } - } + } } diff --git a/Tests/TechTalk.SpecFlow.RuntimeTests/CucumberMessages/CucumberMessageFactoryTests.cs b/Tests/TechTalk.SpecFlow.RuntimeTests/CucumberMessages/CucumberMessageFactoryTests.cs deleted file mode 100644 index 3bd38e289..000000000 --- a/Tests/TechTalk.SpecFlow.RuntimeTests/CucumberMessages/CucumberMessageFactoryTests.cs +++ /dev/null @@ -1,377 +0,0 @@ -using System; -using FluentAssertions; -using Google.Protobuf.WellKnownTypes; -using Io.Cucumber.Messages; -using TechTalk.SpecFlow.CommonModels; -using TechTalk.SpecFlow.CucumberMessages; -using Xunit; - -using static Io.Cucumber.Messages.TestResult.Types; -using static Io.Cucumber.Messages.TestCaseStarted.Types; -using Duration = Io.Cucumber.Messages.Duration; -using Timestamp = Io.Cucumber.Messages.Timestamp; - -namespace TechTalk.SpecFlow.RuntimeTests.CucumberMessages -{ - public class CucumberMessageFactoryTests - { - [Fact(DisplayName = @"BuildTestRunResultMessage should return a TestRunResult message object")] - public void BuildTestRunResultMessage_DateTime_ShouldReturnTestRunResultMessageObject() - { - // ARRANGE - var cucumberMessageFactory = new CucumberMessageFactory(); - var dateTime = new DateTime(2019, 5, 9, 14, 27, 48, DateTimeKind.Utc); - - // ACT - var actualTestRunStartedMessageResult = cucumberMessageFactory.BuildTestRunStartedMessage(dateTime); - - // ASSERT - actualTestRunStartedMessageResult.Should().BeAssignableTo>(); - } - - [Fact(DisplayName = @"BuildTestRunResultMessage should return a TestRunResult message object with the specified date and time")] - public void BuildTestRunResultMessage_DateTime_ShouldReturnTestRunResultMessageObjectWithSpecifiedDateAndTime() - { - // ARRANGE - var cucumberMessageFactory = new CucumberMessageFactory(); - var dateTime = new DateTime(2019, 5, 9, 14, 27, 48, DateTimeKind.Utc); - - // ACT - var actualTestRunStartedMessageResult = cucumberMessageFactory.BuildTestRunStartedMessage(dateTime); - - // ASSERT - actualTestRunStartedMessageResult.Should().BeAssignableTo>() - .Which.Result.Timestamp.ToDateTime().Should().Be(dateTime); - } - - [Theory(DisplayName = @"BuildTestCaseStarted should return a failure when a non-UTC date has been specified")] - [InlineData(DateTimeKind.Local)] - [InlineData(DateTimeKind.Unspecified)] - public void BuildTestRunResultMessage_NonUtcDate_ShouldReturnFailure(DateTimeKind dateTimeKind) - { - // ARRANGE - var cucumberMessageFactory = new CucumberMessageFactory(); - var dateTime = new DateTime(2019, 5, 9, 14, 27, 48, dateTimeKind); - var pickleId = Guid.NewGuid(); - var platform = new Platform - { - Cpu = "x64", - Implementation = "SpecFlow", - Os = "Windows", - Version = "3.1.0" - }; - - // ACT - var result = cucumberMessageFactory.BuildTestCaseStartedMessage(pickleId, dateTime, platform); - - // ASSERT - result.Should().BeAssignableTo(); - } - - [Fact(DisplayName = @"BuildTestCaseStarted should return a message with the correct pickle ID")] - public void BuildTestCaseStarted_ValidData_ShouldReturnMessageWithCorrectPickleId() - { - // ARRANGE - var cucumberMessageFactory = new CucumberMessageFactory(); - var dateTime = new DateTime(2019, 5, 9, 14, 27, 48, DateTimeKind.Utc); - var pickleId = Guid.NewGuid(); - var platform = new Platform - { - Cpu = "x64", - Implementation = "SpecFlow", - Os = "Windows", - Version = "3.1.0" - }; - - // ACT - var result = cucumberMessageFactory.BuildTestCaseStartedMessage(pickleId, dateTime, platform); - - // ASSERT - result.Should().BeAssignableTo>().Which - .Result.PickleId.Should().Be(pickleId.ToString("D")); - } - - [Fact(DisplayName = @"BuildTestCaseStarted should return a success when a UTC date has been specified")] - public void BuildTestCaseStarted_UtcDate_ShouldReturnSuccess() - { - // ARRANGE - var cucumberMessageFactory = new CucumberMessageFactory(); - var dateTime = new DateTime(2019, 5, 9, 14, 27, 48, DateTimeKind.Utc); - var pickleId = Guid.NewGuid(); - var platform = new Platform - { - Cpu = "x64", - Implementation = "SpecFlow", - Os = "Windows", - Version = "3.1.0" - }; - - // ACT - var result = cucumberMessageFactory.BuildTestCaseStartedMessage(pickleId, dateTime, platform); - - // ASSERT - result.Should().BeAssignableTo>(); - } - - [Fact(DisplayName = @"BuildTestCaseStarted should return a success when the platform information has been specified")] - public void BuildTestCaseStarted_PlatformInformation_ShouldReturnSuccess() - { - // ARRANGE - var cucumberMessageFactory = new CucumberMessageFactory(); - var dateTime = new DateTime(2019, 5, 9, 14, 27, 48, DateTimeKind.Utc); - var pickleId = Guid.NewGuid(); - var platform = new Platform - { - Cpu = "x64", - Implementation = "SpecFlow", - Os = "Windows", - Version = "3.1.0" - }; - - // ACT - var result = cucumberMessageFactory.BuildTestCaseStartedMessage(pickleId, dateTime, platform); - - // ASSERT - result.Should().BeAssignableTo>() - .Which.Result.Platform.Should().BeEquivalentTo(platform); - } - - [Fact(DisplayName = @"BuildTestCaseStarted should return a failure when the platform information is null")] - public void BuildTestCaseStarted_PlatformInformationIsNull_ShouldReturnFailue() - { - // ARRANGE - var cucumberMessageFactory = new CucumberMessageFactory(); - var dateTime = new DateTime(2019, 5, 9, 14, 27, 48, DateTimeKind.Utc); - var pickleId = Guid.NewGuid(); - - // ACT - var result = cucumberMessageFactory.BuildTestCaseStartedMessage(pickleId, dateTime, null); - - // ASSERT - result.Should().BeAssignableTo(); - } - - [Fact(DisplayName = @"BuildTestCaseFinished should return a message with the correct pickle ID")] - public void BuildTestCaseFinished_PickleId_ShouldReturnMessageWithCorrectPickleId() - { - // ARRANGE - var cucumberMessageFactory = new CucumberMessageFactory(); - var dateTime = new DateTime(2019, 5, 9, 14, 27, 48, DateTimeKind.Utc); - var pickleId = Guid.NewGuid(); - var testResult = new TestResult - { - Duration = new Duration(){}, - Message = "", - Status = Status.Passed - }; - - // ACT - var result = cucumberMessageFactory.BuildTestCaseFinishedMessage(pickleId, dateTime, testResult); - - // ASSERT - result.Should().BeAssignableTo>().Which - .Result.PickleId.Should().Be(pickleId.ToString("D")); - } - - [Fact(DisplayName = @"BuildTestCaseFinished should return a message with the correct time stamp when a UTC time stamp is passed")] - public void BuildTestCaseFinished_UtcDateTime_ShouldReturnMessageWithCorrectTimeStamp() - { - // ARRANGE - var cucumberMessageFactory = new CucumberMessageFactory(); - var dateTime = new DateTime(2019, 5, 9, 14, 27, 48, DateTimeKind.Utc); - - - var pickleId = Guid.NewGuid(); - var testResult = new TestResult - { - Duration = new Duration(), - Message = "", - Status = Status.Passed - }; - - // ACT - var result = cucumberMessageFactory.BuildTestCaseFinishedMessage(pickleId, dateTime, testResult); - - // ASSERT - result.Should().BeAssignableTo>().Which - .Result.Timestamp.ToDateTime().Should().Be(dateTime); - } - - [Theory(DisplayName = @"BuildTestCaseFinished should return a failure when a non-UTC time stamp is passed")] - [InlineData(DateTimeKind.Local)] - [InlineData(DateTimeKind.Unspecified)] - public void BuildTestCaseFinished_NonUtcDateTime_ShouldReturnFailure(DateTimeKind dateTimeKind) - { - // ARRANGE - var cucumberMessageFactory = new CucumberMessageFactory(); - var dateTime = new DateTime(2019, 5, 9, 14, 27, 48, dateTimeKind); - var pickleId = Guid.NewGuid(); - var testResult = new TestResult - { - Duration = new Duration(), - Message = "", - Status = Status.Passed - }; - - // ACT - var result = cucumberMessageFactory.BuildTestCaseFinishedMessage(pickleId, dateTime, testResult); - - // ASSERT - result.Should().BeAssignableTo>(); - } - - [Fact(DisplayName = @"BuildTestCaseFinished should return a message with the correct TestResult")] - public void BuildTestCaseFinished_TestResult_ShouldReturnMessageWithCorrectTestResult() - { - // ARRANGE - var cucumberMessageFactory = new CucumberMessageFactory(); - var dateTime = new DateTime(2019, 5, 9, 14, 27, 48, DateTimeKind.Utc); - var pickleId = Guid.NewGuid(); - var testResult = new TestResult - { - Duration = new Duration() { }, - Message = "", - Status = Status.Passed - }; - - // ACT - var result = cucumberMessageFactory.BuildTestCaseFinishedMessage(pickleId, dateTime, testResult); - - // ASSERT - result.Should().BeAssignableTo>().Which - .Result.TestResult.Should().Be(testResult); - } - - [Fact(DisplayName = @"BuildTestCaseFinished should return a failure with exception information when null has been specified as TestResult")] - public void BuildTestCaseFinished_NullTestResult_ShouldReturnExceptionFailure() - { - // ARRANGE - var cucumberMessageFactory = new CucumberMessageFactory(); - var dateTime = new DateTime(2019, 5, 9, 14, 27, 48, DateTimeKind.Utc); - var pickleId = Guid.NewGuid(); - - // ACT - var result = cucumberMessageFactory.BuildTestCaseFinishedMessage(pickleId, dateTime, default); - - // ASSERT - result.Should().BeAssignableTo>().Which - .Exception.Should().BeOfType(); - } - - [Fact(DisplayName = @"BuildEnvelopeMessage should return an envelope of type TestCaseFinished")] - public void BuildEnvelopeMessage_TestCaseFinishedSuccess_ShouldReturnEnvelopeOfTypeTestCaseFinished() - { - // ARRANGE - var cucumberMessageFactory = new CucumberMessageFactory(); - var testCaseFinished = new TestCaseFinished - { - PickleId = Guid.NewGuid().ToString(), - TestResult = new TestResult(), - Timestamp = new Timestamp() - }; - - // ACT - var result = cucumberMessageFactory.BuildEnvelopeMessage(new Success(testCaseFinished)); - - // ASSERT - result.Should().BeAssignableTo>().Which - .Result.MessageCase.Should().Be(Envelope.MessageOneofCase.TestCaseFinished); - } - - [Fact(DisplayName = @"BuildEnvelopeMessage should return an envelope with the passed TestCaseFinished message")] - public void BuildEnvelopeMessage_TestCaseFinishedSuccess_ShouldReturnEnvelopeWithTestCaseFinishedMessage() - { - // ARRANGE - var cucumberMessageFactory = new CucumberMessageFactory(); - var testCaseFinished = new TestCaseFinished - { - PickleId = Guid.NewGuid().ToString(), - TestResult = new TestResult(), - Timestamp = new Timestamp() - }; - - // ACT - var result = cucumberMessageFactory.BuildEnvelopeMessage(new Success(testCaseFinished)); - - // ASSERT - result.Should().BeAssignableTo>().Which - .Result.TestCaseFinished.Should().Be(testCaseFinished); - } - - [Fact(DisplayName = @"BuildTestRunFinishedMessage should return a TestRunFinished message")] - public void BuildTestRunFinished_Success_ShouldReturnTestRunFinishedMessage() - { - // ARRANGE - var cucumberMessageFactory = new CucumberMessageFactory(); - var dateTime = new DateTime(2019, 5, 9, 14, 27, 48, DateTimeKind.Utc); - - // ACT - var result = cucumberMessageFactory.BuildTestRunFinishedMessage(true, dateTime); - - // ASSERT - result.Should().BeAssignableTo>(); - } - - [Theory(DisplayName = @"BuildTestRunFinishedMessage should return a TestRunFinished message with the specified success value")] - [InlineData(true, true)] - [InlineData(false, false)] - public void BuildTestRunFinished_SuccessValue_ShouldReturnTestRunFinishedMessageWithSpecifiedSuccessValue(bool inputSuccess, bool expectedSuccess) - { - // ARRANGE - var cucumberMessageFactory = new CucumberMessageFactory(); - var dateTime = new DateTime(2019, 5, 9, 14, 27, 48, DateTimeKind.Utc); - - // ACT - var result = cucumberMessageFactory.BuildTestRunFinishedMessage(inputSuccess, dateTime); - - // ASSERT - result.Should().BeAssignableTo>().Which - .Result.Success.Should().Be(expectedSuccess); - } - - [Theory] - [InlineData(DateTimeKind.Local)] - [InlineData(DateTimeKind.Unspecified)] - public void BuildTestRunFinished_DateTimeWithInvalidKind_ShouldReturnFailure(DateTimeKind dateTimeKind) - { - // ARRANGE - var cucumberMessageFactory = new CucumberMessageFactory(); - var dateTime = new DateTime(2019, 5, 9, 14, 27, 48, dateTimeKind); - - // ACT - var result = cucumberMessageFactory.BuildTestRunFinishedMessage(true, dateTime); - - // ASSERT - result.Should().BeAssignableTo>(); - } - - [Fact] - public void BuildTestRunFinished_UtcDateTime_ShouldReturnSuccess() - { - // ARRANGE - var cucumberMessageFactory = new CucumberMessageFactory(); - var dateTime = new DateTime(2019, 5, 9, 14, 27, 48, DateTimeKind.Utc); - - // ACT - var result = cucumberMessageFactory.BuildTestRunFinishedMessage(true, dateTime); - - // ASSERT - result.Should().BeAssignableTo>(); - } - - [Fact] - public void BuildTestRunFinished_UtcDateTime_ShouldReturnSuccessWithSpecifiedTimeStamp() - { - // ARRANGE - var cucumberMessageFactory = new CucumberMessageFactory(); - var dateTime = new DateTime(2019, 5, 9, 14, 27, 48, DateTimeKind.Utc); - - // ACT - var result = cucumberMessageFactory.BuildTestRunFinishedMessage(true, dateTime); - - // ASSERT - result.Should().BeAssignableTo>() - .Which.Result.Timestamp.ToDateTime().Should().Be(dateTime); - } - } -} diff --git a/Tests/TechTalk.SpecFlow.RuntimeTests/CucumberMessages/CucumberMessageSenderTests.cs b/Tests/TechTalk.SpecFlow.RuntimeTests/CucumberMessages/CucumberMessageSenderTests.cs deleted file mode 100644 index 02826c363..000000000 --- a/Tests/TechTalk.SpecFlow.RuntimeTests/CucumberMessages/CucumberMessageSenderTests.cs +++ /dev/null @@ -1,170 +0,0 @@ -using System; -using System.Collections.Generic; -using FluentAssertions; -using Google.Protobuf.WellKnownTypes; -using Io.Cucumber.Messages; -using Moq; -using TechTalk.SpecFlow.CommonModels; -using TechTalk.SpecFlow.CucumberMessages; -using Xunit; - -namespace TechTalk.SpecFlow.RuntimeTests.CucumberMessages -{ - public class CucumberMessageSenderTests - { - [Fact(DisplayName = @"SendTestCaseStarted should send a TestCaseStarted message to sink")] - public void SendTestCaseStarted_ValidParameters_ShouldSendTestRunStartedToSink() - { - // ARRANGE - Envelope sentMessage = default; - - var cucumberMessageSinkMock = new Mock(); - cucumberMessageSinkMock.Setup(m => m.SendMessage(It.IsAny())) - .Callback(m => sentMessage = m); - - var cucumberMessageFactoryMock = GetCucumberMessageFactoryMock(); - var fieldValueProviderMock = GetFieldValueProviderMock(); - var platformFactoryMock = GetPlatformFactoryMock(); - var testRunResultSuccessCalculatorMock = GetTestRunResultSuccessCalculatorMock(); - - var sinkProviderMock = new Mock(); - sinkProviderMock.Setup(m => m.GetMessageSinksFromConfiguration()).Returns(new List() { cucumberMessageSinkMock.Object }); - var cucumberMessageSender = new CucumberMessageSender(cucumberMessageFactoryMock.Object, platformFactoryMock.Object, fieldValueProviderMock.Object, testRunResultSuccessCalculatorMock.Object, sinkProviderMock.Object); - var scenarioInfo = new ScenarioInfo("Test", "Description", new string[] { "Tag1" }, null); - - // ACT - cucumberMessageSender.SendTestCaseStarted(scenarioInfo); - - // ASSERT - sentMessage.MessageCase.Should().Be(Envelope.MessageOneofCase.TestCaseStarted); - } - - public Mock GetTestRunResultSuccessCalculatorMock(bool isSuccess = true) - { - var testRunResultSuccessCalculatorMock = new Mock(); - testRunResultSuccessCalculatorMock.Setup(m => m.IsSuccess(It.IsAny())) - .Returns(isSuccess); - return testRunResultSuccessCalculatorMock; - } - - public Mock GetPlatformFactoryMock() - { - var platformFactoryMock = new Mock(); - platformFactoryMock.Setup(m => m.BuildFromSystemInformation()) - .Returns( - new TestCaseStarted.Types.Platform - { - Cpu = "x64", - Os = "Windows", - Implementation = "SpecFlow", - Version = "3.1.0" - }); - return platformFactoryMock; - } - - [Fact(DisplayName = @"SendTestRunStarted should send a TestRunStated message to sink")] - public void SendTestRunStarted_ShouldSendTestRunStartedToSink() - { - // ARRANGE - Envelope sentMessage = default; - - var cucumberMessageSinkMock = new Mock(); - cucumberMessageSinkMock.Setup(m => m.SendMessage(It.IsAny())) - .Callback(m => sentMessage = m); - - var cucumberMessageFactoryMock = GetCucumberMessageFactoryMock(); - var fieldValueProviderMock = GetFieldValueProviderMock(); - var platformFactoryMock = GetPlatformFactoryMock(); - var testRunResultSuccessCalculatorMock = GetTestRunResultSuccessCalculatorMock(); - - var sinkProviderMock = new Mock(); - sinkProviderMock.Setup(m => m.GetMessageSinksFromConfiguration()).Returns(new List() { cucumberMessageSinkMock.Object }); - - var cucumberMessageSender = new CucumberMessageSender(cucumberMessageFactoryMock.Object, platformFactoryMock.Object, fieldValueProviderMock.Object, testRunResultSuccessCalculatorMock.Object, sinkProviderMock.Object); - - // ACT - cucumberMessageSender.SendTestRunStarted(); - - // ASSERT - sentMessage.MessageCase.Should().Be(Envelope.MessageOneofCase.TestRunStarted); - } - - [Fact(DisplayName = @"SendTestRunStarted should send a TestRunStated message with correct time stamp to sink")] - public void SendTestRunStarted_ShouldSendTestRunStartedWithCorrectTimeStampToSink() - { - // ARRANGE - var now = new DateTime(2019, 5, 9, 15, 46, 5, DateTimeKind.Utc); - - Envelope sentMessage = default; - - var cucumberMessageSinkMock = new Mock(); - cucumberMessageSinkMock.Setup(m => m.SendMessage(It.IsAny())) - .Callback(m => sentMessage = m); - - var cucumberMessageFactoryMock = GetCucumberMessageFactoryMock(); - var fieldValueProviderMock = GetFieldValueProviderMock(testRunStartedTimeStamp: now); - var platformFactoryMock = GetPlatformFactoryMock(); - var testRunResultSuccessCalculatorMock = GetTestRunResultSuccessCalculatorMock(); - - var sinkProviderMock = new Mock(); - sinkProviderMock.Setup(m => m.GetMessageSinksFromConfiguration()).Returns(new List() { cucumberMessageSinkMock.Object }); - - var cucumberMessageSender = new CucumberMessageSender(cucumberMessageFactoryMock.Object, platformFactoryMock.Object, fieldValueProviderMock.Object, testRunResultSuccessCalculatorMock.Object, sinkProviderMock.Object); - - // ACT - cucumberMessageSender.SendTestRunStarted(); - - // ASSERT - sentMessage.MessageCase.Should().Be(Envelope.MessageOneofCase.TestRunStarted); - sentMessage.TestRunStarted.Timestamp.ToDateTime().Should().Be(now); - } - - public Mock GetCucumberMessageFactoryMock() - { - var cucumberMessageFactoryMock = new Mock(); - cucumberMessageFactoryMock.Setup(m => m.BuildEnvelopeMessage(It.IsAny>())) - .Returns>(r => Result.Success(new Envelope { TestCaseStarted = r.Result })); - - cucumberMessageFactoryMock.Setup(m => m.BuildEnvelopeMessage(It.IsAny>())) - .Returns>(r => Result.Success(new Envelope { TestRunStarted = r.Result })); - - cucumberMessageFactoryMock.Setup(m => m.BuildTestRunStartedMessage(It.IsAny())) - .Returns(timeStamp => Result.Success( - new TestRunStarted - { - Timestamp = timeStamp.ToCucumberMessagesTimestamp() - })); - - cucumberMessageFactoryMock.Setup(m => m.BuildTestCaseStartedMessage(It.IsAny(), It.IsAny(), It.IsAny())) - .Returns((id, timeStamp, platform) => Result.Success( - new TestCaseStarted - { - PickleId = $"{id:D}", - Timestamp = timeStamp.ToCucumberMessagesTimestamp(), - Platform = platform - })); - return cucumberMessageFactoryMock; - } - - public Mock GetFieldValueProviderMock( - DateTime? testRunStartedTimeStamp = default, - DateTime? testCaseStartedTimeStamp = default, - Guid? testCaseStartedPickleId = default, - DateTime? testCaseFinishedTimeStamp = default, - Guid? testCaseFinishedPickleId = default) - { - var fieldValueProviderMock = new Mock(); - fieldValueProviderMock.Setup(m => m.GetTestRunStartedTime()) - .Returns(() => testRunStartedTimeStamp ?? DateTime.UtcNow); - fieldValueProviderMock.Setup(m => m.GetTestCaseStartedTime()) - .Returns(() => testCaseStartedTimeStamp ?? DateTime.UtcNow); - fieldValueProviderMock.Setup(m => m.GetTestCaseStartedPickleId(It.IsAny())) - .Returns(testCaseStartedPickleId ?? Guid.NewGuid()); - fieldValueProviderMock.Setup(m => m.GetTestCaseFinishedTime()) - .Returns(() => testCaseFinishedTimeStamp ?? DateTime.UtcNow); - fieldValueProviderMock.Setup(m => m.GetTestCaseFinishedPickleId(It.IsAny())) - .Returns(testCaseFinishedPickleId ?? Guid.NewGuid()); - return fieldValueProviderMock; - } - } -} diff --git a/Tests/TechTalk.SpecFlow.RuntimeTests/CucumberMessages/NonStrictTestRunResultSuccessCalculatorTests.cs b/Tests/TechTalk.SpecFlow.RuntimeTests/CucumberMessages/NonStrictTestRunResultSuccessCalculatorTests.cs deleted file mode 100644 index 2d57030db..000000000 --- a/Tests/TechTalk.SpecFlow.RuntimeTests/CucumberMessages/NonStrictTestRunResultSuccessCalculatorTests.cs +++ /dev/null @@ -1,60 +0,0 @@ -using FluentAssertions; -using TechTalk.SpecFlow.CucumberMessages; -using Xunit; - -namespace TechTalk.SpecFlow.RuntimeTests.CucumberMessages -{ - public class NonStrictTestRunResultSuccessCalculatorTests - { - [Theory] - [InlineData(0, 1, 0, 0, 0)] - [InlineData(0, 0, 0, 1, 0)] - [InlineData(1, 1, 0, 0, 0)] - [InlineData(0, 1, 1, 0, 0)] - [InlineData(0, 1, 1, 1, 0)] - [InlineData(0, 1, 1, 1, 1)] - [InlineData(1, 1, 1, 1, 1)] - public void IsSuccess_NoSuccessData_ShouldReturnFalse(int passed, int failed, int skipped, int ambiguous, int undefined) - { - // ARRANGE - var nonStrictTestRunResultSuccessCalculator = new NonStrictTestRunResultSuccessCalculator(); - var testRunResult = new TestRunResult( - passed + failed + skipped + ambiguous + undefined, - passed, - failed, - skipped, - ambiguous, - undefined); - - // ACT - bool isSuccess = nonStrictTestRunResultSuccessCalculator.IsSuccess(testRunResult); - - // ASSERT - isSuccess.Should().BeFalse(); - } - - [Theory] - [InlineData(0, 0, 1, 0, 0)] - [InlineData(0, 0, 0, 0, 1)] - [InlineData(1, 0, 0, 0, 1)] - [InlineData(1, 0, 0, 0, 0)] - public void IsSuccess_SuccessData_ShouldReturnTrue(int passed, int failed, int skipped, int ambiguous, int undefined) - { - // ARRANGE - var nonStrictTestRunResultSuccessCalculator = new NonStrictTestRunResultSuccessCalculator(); - var testRunResult = new TestRunResult( - passed + failed + skipped + ambiguous + undefined, - passed, - failed, - skipped, - ambiguous, - undefined); - - // ACT - bool isSuccess = nonStrictTestRunResultSuccessCalculator.IsSuccess(testRunResult); - - // ASSERT - isSuccess.Should().BeTrue(); - } - } -} diff --git a/Tests/TechTalk.SpecFlow.RuntimeTests/CucumberMessages/PickleIdStoreTests.cs b/Tests/TechTalk.SpecFlow.RuntimeTests/CucumberMessages/PickleIdStoreTests.cs deleted file mode 100644 index ee3846946..000000000 --- a/Tests/TechTalk.SpecFlow.RuntimeTests/CucumberMessages/PickleIdStoreTests.cs +++ /dev/null @@ -1,88 +0,0 @@ -using System; -using System.Collections.Generic; -using FluentAssertions; -using Moq; -using TechTalk.SpecFlow.CucumberMessages; -using Xunit; - -namespace TechTalk.SpecFlow.RuntimeTests.CucumberMessages -{ - public class PickleIdStoreTests - { - [Fact(DisplayName = @"GetPickleIdForScenarioInfo should add a Pickle ID to the dictionary if it does not already exist")] - public void GetPickleIdForScenarioInfo_ScenarioInfo_ShouldAddPickleIdToDictionaryIfNotExistent() - { - // ARRANGE - var dictionary = new Dictionary(); - var pickleIdStoreDictionaryFactoryMock = GetPickleIdStoreDictionaryFactoryMock(dictionary); - var guidToCreate = new Guid(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11); - var scenarioInfo = new ScenarioInfo("Title", "Description", null, null); - var mock = GetPickleIdGeneratorMock(guidToCreate); - - var pickleIdStore = new PickleIdStore(mock.Object, pickleIdStoreDictionaryFactoryMock.Object); - - // ACT - pickleIdStore.GetPickleIdForScenario(scenarioInfo); - - // ASSERT - dictionary.Should().Contain(scenarioInfo, guidToCreate); - } - - [Fact(DisplayName = @"GetPickleIdForScenarioInfo should return the Pickle ID if it already exists")] - public void GetPickleIdForScenarioInfo_ScenarioInfo_ShouldReturnPickleIdIfAlreadyExists() - { - // ARRANGE - var existingGuid = new Guid(11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1); - var guidToCreate = new Guid(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11); - var scenarioInfo = new ScenarioInfo("Title", "Description", null, null); - var dictionary = new Dictionary { [scenarioInfo] = existingGuid }; - var pickleIdStoreDictionaryFactoryMock = GetPickleIdStoreDictionaryFactoryMock(dictionary); - var mock = GetPickleIdGeneratorMock(guidToCreate); - - var pickleIdStore = new PickleIdStore(mock.Object, pickleIdStoreDictionaryFactoryMock.Object); - - // ACT - var actualReturnedGuid = pickleIdStore.GetPickleIdForScenario(scenarioInfo); - - // ASSERT - actualReturnedGuid.Should().Be(existingGuid); - } - - [Fact(DisplayName = @"GetPickleIdForScenarioInfo should not overwrite the Pickle ID for already existing entries")] - public void GetPickleIdForScenarioInfo_ScenarioInfo_ShouldNotOverwritePickleIdIfAlreadyExists() - { - // ARRANGE - var existingGuid = new Guid(11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1); - var guidToCreate = new Guid(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11); - var scenarioInfo = new ScenarioInfo("Title", "Description", null, null); - var dictionary = new Dictionary { [scenarioInfo] = existingGuid }; - var pickleIdStoreDictionaryFactoryMock = GetPickleIdStoreDictionaryFactoryMock(dictionary); - var mock = GetPickleIdGeneratorMock(guidToCreate); - - var pickleIdStore = new PickleIdStore(mock.Object, pickleIdStoreDictionaryFactoryMock.Object); - - // ACT - pickleIdStore.GetPickleIdForScenario(scenarioInfo); - - // ASSERT - dictionary.Should().Contain(scenarioInfo, existingGuid) - .And.NotContain(scenarioInfo, guidToCreate); - } - - public Mock GetPickleIdStoreDictionaryFactoryMock(Dictionary dictionary) - { - var pickleIdStoreDictionaryFactoryMock = new Mock(); - pickleIdStoreDictionaryFactoryMock.Setup(m => m.BuildDictionary()) - .Returns(dictionary); - return pickleIdStoreDictionaryFactoryMock; - } - - public Mock GetPickleIdGeneratorMock(Guid guidToCreate) - { - var mock = new Mock(); - mock.Setup(m => m.GeneratePickleId()) - .Returns(guidToCreate); - return mock; - } - } -} diff --git a/Tests/TechTalk.SpecFlow.RuntimeTests/CucumberMessages/PlatformFactoryTests.cs b/Tests/TechTalk.SpecFlow.RuntimeTests/CucumberMessages/PlatformFactoryTests.cs deleted file mode 100644 index 2087a7550..000000000 --- a/Tests/TechTalk.SpecFlow.RuntimeTests/CucumberMessages/PlatformFactoryTests.cs +++ /dev/null @@ -1,100 +0,0 @@ -using FluentAssertions; -using Moq; -using TechTalk.SpecFlow.CucumberMessages; -using Xunit; - -namespace TechTalk.SpecFlow.RuntimeTests.CucumberMessages -{ - public class PlatformFactoryTests - { - [Fact(DisplayName = @"BuildFromSystemInformation should return a success with the system's CPU architecture")] - public void BuildFromSystemInformation_CpuArchitecture_ShouldReturnSuccessWithSystemCpuArchitecture() - { - // ARRANGE - const string cpuArchitecture = "x86"; - - var systemInformationProviderMock = GetSystemInformationProviderMock(cpuArchitecture: cpuArchitecture); - var specFlowVersionInformationProvider = GetSpecFlowVersionInformationProvider(); - - var platformFactory = new PlatformFactory(systemInformationProviderMock.Object, specFlowVersionInformationProvider.Object); - - // ACT - var result = platformFactory.BuildFromSystemInformation(); - - // ASSERT - result.Cpu.Should().Be(cpuArchitecture); - } - - [Fact(DisplayName = @"BuildFromSystemInformation should return a success with the system's operating system")] - public void BuildFromSystemInformation_OperatingSystem_ShouldReturnSuccessWithOperatingSystem() - { - // ARRANGE - const string operatingSystem = "Ubuntu"; - - var systemInformationProviderMock = GetSystemInformationProviderMock(operatingSystem: operatingSystem); - var specFlowVersionInformationProvider = GetSpecFlowVersionInformationProvider(); - - var platformFactory = new PlatformFactory(systemInformationProviderMock.Object, specFlowVersionInformationProvider.Object); - - // ACT - var result = platformFactory.BuildFromSystemInformation(); - - // ASSERT - result.Os.Should().Be(operatingSystem); - } - - [Fact(DisplayName = @"BuildFromSystemInformation should return a success with the current SpecFlow version")] - public void BuildFromSystemInformation_PackageVersion_ShouldReturnSuccessWithVersion() - { - // ARRANGE - const string packageVersion = "3.1.0"; - - var systemInformationProviderMock = GetSystemInformationProviderMock(); - var specFlowVersionInformationProvider = GetSpecFlowVersionInformationProvider(packageVersion); - - var platformFactory = new PlatformFactory(systemInformationProviderMock.Object, specFlowVersionInformationProvider.Object); - - // ACT - var result = platformFactory.BuildFromSystemInformation(); - - // ASSERT - result.Version.Should().Be(packageVersion); - } - - [Fact(DisplayName = @"BuildFromSystemInformation should return a success with SpecFlow as implementation")] - public void BuildFromSystemInformation_ShouldReturnSuccessWithSpecFlowAsImplementation() - { - // ARRANGE - const string expectedImplementation = "SpecFlow"; - - var systemInformationProviderMock = GetSystemInformationProviderMock(); - var specFlowVersionInformationProvider = GetSpecFlowVersionInformationProvider(); - - var platformFactory = new PlatformFactory(systemInformationProviderMock.Object, specFlowVersionInformationProvider.Object); - - // ACT - var result = platformFactory.BuildFromSystemInformation(); - - // ASSERT - result.Implementation.Should().Be(expectedImplementation); - } - - public Mock GetSpecFlowVersionInformationProvider(string packageVersion = "3.1.0") - { - var specFlowVersionInformationProvider = new Mock(); - specFlowVersionInformationProvider.Setup(m => m.GetAssemblyVersion()) - .Returns(packageVersion); - return specFlowVersionInformationProvider; - } - - public Mock GetSystemInformationProviderMock(string cpuArchitecture = "x64", string operatingSystem = "Windows") - { - var systemInformationProviderMock = new Mock(); - systemInformationProviderMock.Setup(m => m.GetCpuArchitecture()) - .Returns(cpuArchitecture); - systemInformationProviderMock.Setup(m => m.GetOperatingSystem()) - .Returns(operatingSystem); - return systemInformationProviderMock; - } - } -} diff --git a/Tests/TechTalk.SpecFlow.RuntimeTests/CucumberMessages/SinkProviderTests.cs b/Tests/TechTalk.SpecFlow.RuntimeTests/CucumberMessages/SinkProviderTests.cs deleted file mode 100644 index 66eb049d1..000000000 --- a/Tests/TechTalk.SpecFlow.RuntimeTests/CucumberMessages/SinkProviderTests.cs +++ /dev/null @@ -1,81 +0,0 @@ -using System; -using System.Linq; -using FluentAssertions; -using Moq; -using TechTalk.SpecFlow.Configuration; -using TechTalk.SpecFlow.CucumberMessages; -using TechTalk.SpecFlow.CucumberMessages.Sinks; -using TechTalk.SpecFlow.FileAccess; -using Xunit; - -namespace TechTalk.SpecFlow.RuntimeTests.CucumberMessages -{ - public class SinkProviderTests - { - [Fact(DisplayName = "When cucumber-messages are not configured, no sinks are returned")] - public void GetMessageSinksFromConfiguration_Cucumber_Messages_Are_Not_Configured__No_Sink() - { - var specFlowConfiguration = ConfigurationLoader.GetDefault(); - - var sinkProvider = new SinkProvider(specFlowConfiguration, new Mock().Object, new Mock().Object); - - sinkProvider.GetMessageSinksFromConfiguration().Should().BeEmpty(); - } - - [Fact(DisplayName = "When cucumber-messages are disabled, no sinks are returned")] - public void GetMessageSinksFromConfiguration_Cucumber_Messages_Are_Disabled__No_Sink() - { - var specFlowConfiguration = ConfigurationLoader.GetDefault(); - specFlowConfiguration.CucumberMessagesConfiguration.Enabled = false; - - var sinkProvider = new SinkProvider(specFlowConfiguration, new Mock().Object, new Mock().Object); - - sinkProvider.GetMessageSinksFromConfiguration().Should().BeEmpty(); - } - - - [Fact(DisplayName = "When cucumber-messages are enabled, but nothing else configured, the default sink is returned")] - public void GetMessageSinksFromConfiguration_Cucumber_Messages_Are_Enabled__Default_Sink() - { - var specFlowConfiguration = ConfigurationLoader.GetDefault(); - specFlowConfiguration.CucumberMessagesConfiguration.Enabled = true; - - var sinkProvider = new SinkProvider(specFlowConfiguration, new Mock().Object, new Mock().Object); - - sinkProvider.GetMessageSinksFromConfiguration().Should().HaveCount(1); - var cucumberMessageSink = sinkProvider.GetMessageSinksFromConfiguration().First(); - cucumberMessageSink.Should().BeOfType(); - } - - [Fact(DisplayName = "When cucumber-messages sinks are configured, these are used")] - public void GetMessageSinksFromConfiguration_CustomSinks_are_configured__These_are_returned() - { - var specFlowConfiguration = ConfigurationLoader.GetDefault(); - specFlowConfiguration.CucumberMessagesConfiguration.Enabled = true; - - specFlowConfiguration.CucumberMessagesConfiguration.Sinks.Add(new CucumberMessagesSink("file", "path_to_something")); - specFlowConfiguration.CucumberMessagesConfiguration.Sinks.Add(new CucumberMessagesSink("file", "path_to_something_else")); - - var sinkProvider = new SinkProvider(specFlowConfiguration, new Mock().Object, new Mock().Object); - - var messageSinksFromConfiguration = sinkProvider.GetMessageSinksFromConfiguration(); - messageSinksFromConfiguration.Should().HaveCount(2); - messageSinksFromConfiguration.Should().AllBeOfType(); - } - - [Fact(DisplayName = "When unknown cucumber-messages sinks are configured, there is an error")] - public void GetMessageSinksFromConfiguration_Unknown_sinks_are_configured__Error_is_thrown() - { - var specFlowConfiguration = ConfigurationLoader.GetDefault(); - specFlowConfiguration.CucumberMessagesConfiguration.Enabled = true; - - specFlowConfiguration.CucumberMessagesConfiguration.Sinks.Add(new CucumberMessagesSink("unknown_type", "path_to_something")); - - var sinkProvider = new SinkProvider(specFlowConfiguration, new Mock().Object, new Mock().Object); - - Action action = () => sinkProvider.GetMessageSinksFromConfiguration(); - action.Should().Throw().WithMessage("The sink type unknown_type"); - - } - } -} \ No newline at end of file diff --git a/Tests/TechTalk.SpecFlow.RuntimeTests/CucumberMessages/Sinks/ProtobufFileSinkOutputTests.cs b/Tests/TechTalk.SpecFlow.RuntimeTests/CucumberMessages/Sinks/ProtobufFileSinkOutputTests.cs deleted file mode 100644 index 28efc6c90..000000000 --- a/Tests/TechTalk.SpecFlow.RuntimeTests/CucumberMessages/Sinks/ProtobufFileSinkOutputTests.cs +++ /dev/null @@ -1,90 +0,0 @@ -using System; -using System.IO; -using FluentAssertions; -using Google.Protobuf.WellKnownTypes; -using Io.Cucumber.Messages; -using Moq; -using TechTalk.SpecFlow.CommonModels; -using TechTalk.SpecFlow.CucumberMessages.Sinks; -using TechTalk.SpecFlow.FileAccess; -using Xunit; - -namespace TechTalk.SpecFlow.RuntimeTests.CucumberMessages.Sinks -{ - public class ProtobufFileSinkOutputTests - { - [Fact(DisplayName = @"WriteMessage should return success if the ProtobufFileSinkOutput is initialized")] - public void WriteMessage_Message_ShouldReturnSuccessIfInitialized() - { - // ARRANGE - var message = new Envelope { TestRunStarted = new TestRunStarted()}; - var protobufFileSinkConfiguration = GetProtobufFileSinkConfiguration(); - var binaryFileAccessorMock = GetBinaryFileAccessorMock(); - var protobufFileNameResolverMock = GetProtobufFileNameResolverMock(); - - var protobufFileSinkOutput = new ProtobufFileSinkOutput(binaryFileAccessorMock.Object, protobufFileSinkConfiguration, protobufFileNameResolverMock.Object); - - // ACT - var actualResult = protobufFileSinkOutput.WriteMessage(message); - - // ASSERT - actualResult.Should().BeAssignableTo(); - } - - [Fact(DisplayName = @"WriteMessage should write the specified message to OutputStream")] - public void WriteMessage_Message_ShouldWriteTheSpecifiedMessageToOutputStream() - { - // ARRANGE - var message = new Envelope - { - TestRunStarted = new TestRunStarted - { - } - }; - - var protobufFileSinkConfiguration = GetProtobufFileSinkConfiguration(); - var writableStream = GetWritableStream(); - var binaryFileAccessorMock = GetBinaryFileAccessorMock(Result.Success(writableStream)); - var protobufFileNameResolverMock = GetProtobufFileNameResolverMock(); - - var protobufFileSinkOutput = new ProtobufFileSinkOutput(binaryFileAccessorMock.Object, protobufFileSinkConfiguration, protobufFileNameResolverMock.Object); - - // ACT - protobufFileSinkOutput.WriteMessage(message); - - // ASSERT - writableStream.ToArray().Length.Should().BeGreaterThan(0); - } - - public Mock GetBinaryFileAccessorMock(IResult openOrAppendStream = null) - { - var binaryFileAccessorMock = new Mock(); - binaryFileAccessorMock.Setup(m => m.OpenAppendOrCreateFile(It.IsAny())) - .Returns(openOrAppendStream ?? Result.Success(GetWritableStream())); - return binaryFileAccessorMock; - } - - public Mock GetProtobufFileNameResolverMock() - { - var protobufFileNameResolverMock = new Mock(); - protobufFileNameResolverMock.Setup(m => m.Resolve(It.IsAny())) - .Returns(Result.Success); - return protobufFileNameResolverMock; - } - - public Stream GetNotWritableStream() - { - return new MemoryStream(new byte[0], false); - } - - public MemoryStream GetWritableStream() - { - return new MemoryStream(); - } - - public ProtobufFileSinkConfiguration GetProtobufFileSinkConfiguration(string targetFilePath = "cucumbermessages") - { - return new ProtobufFileSinkConfiguration(targetFilePath); - } - } -} diff --git a/Tests/TechTalk.SpecFlow.RuntimeTests/CucumberMessages/StrictTestRunResultSuccessCalculatorTests.cs b/Tests/TechTalk.SpecFlow.RuntimeTests/CucumberMessages/StrictTestRunResultSuccessCalculatorTests.cs deleted file mode 100644 index 372301d46..000000000 --- a/Tests/TechTalk.SpecFlow.RuntimeTests/CucumberMessages/StrictTestRunResultSuccessCalculatorTests.cs +++ /dev/null @@ -1,38 +0,0 @@ -using FluentAssertions; -using TechTalk.SpecFlow.CucumberMessages; -using Xunit; - -namespace TechTalk.SpecFlow.RuntimeTests.CucumberMessages -{ - public class StrictTestRunResultSuccessCalculatorTests - { - [Theory] - [InlineData(0, 1, 0, 0, 0)] - [InlineData(0, 0, 1, 0, 0)] - [InlineData(0, 0, 0, 1, 0)] - [InlineData(0, 0, 0, 0, 1)] - [InlineData(1, 0, 0, 0, 1)] - [InlineData(0, 1, 1, 0, 0)] - [InlineData(0, 1, 1, 1, 0)] - [InlineData(0, 1, 1, 1, 1)] - [InlineData(1, 1, 1, 1, 1)] - public void IsSuccess_NoSuccessData_ShouldReturnFalse(int passed, int failed, int skipped, int ambiguous, int undefined) - { - // ARRANGE - var strictTestRunResultSuccessCalculator = new StrictTestRunResultSuccessCalculator(); - var testRunResult = new TestRunResult( - passed + failed + skipped + ambiguous + undefined, - passed, - failed, - skipped, - ambiguous, - undefined); - - // ACT - bool isSuccess = strictTestRunResultSuccessCalculator.IsSuccess(testRunResult); - - // ASSERT - isSuccess.Should().BeFalse(); - } - } -} diff --git a/Tests/TechTalk.SpecFlow.RuntimeTests/CucumberMessages/TestResultFactoryTests.cs b/Tests/TechTalk.SpecFlow.RuntimeTests/CucumberMessages/TestResultFactoryTests.cs deleted file mode 100644 index 844370ede..000000000 --- a/Tests/TechTalk.SpecFlow.RuntimeTests/CucumberMessages/TestResultFactoryTests.cs +++ /dev/null @@ -1,90 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq.Expressions; -using FluentAssertions; -using Io.Cucumber.Messages; -using Moq; -using TechTalk.SpecFlow.CommonModels; -using TechTalk.SpecFlow.CucumberMessages; -using Xunit; - -namespace TechTalk.SpecFlow.RuntimeTests.CucumberMessages -{ - public class TestResultFactoryTests - { - private ScenarioContext CreateScenarioContext(ScenarioExecutionStatus scenarioExecutionStatus) - { - return new ScenarioContext(null, new ScenarioInfo("","", null, null), null) - { - ScenarioExecutionStatus = scenarioExecutionStatus - }; - } - - [Fact(DisplayName = @"BuildFromScenarioContext should return a failure with an ArgumentNullException when null is passed")] - public void BuildFromScenarioContext_Null_ShouldReturnFailureWithArgumentNullException() - { - // ARRANGE - var testResultFactory = new TestResultFactory(new Mock().Object); - - // ACT - var actualTestResult = testResultFactory.BuildFromContext(null, null); - - // ASSERT - actualTestResult.Should().BeAssignableTo().Which - .Exception.Should().BeOfType(); - } - - - private static Dictionary>> _testCases = new Dictionary>>() - { - { ScenarioExecutionStatus.OK, (factory => factory.BuildPassedResult(It.IsAny()))}, - { ScenarioExecutionStatus.BindingError, (factory => factory.BuildAmbiguousResult(It.IsAny(), It.IsAny()))}, - { ScenarioExecutionStatus.StepDefinitionPending, (factory => factory.BuildPendingResult(It.IsAny(), It.IsAny()))}, - { ScenarioExecutionStatus.TestError, (factory => factory.BuildFailedResult(It.IsAny(), It.IsAny()))}, - { ScenarioExecutionStatus.UndefinedStep, (factory => factory.BuildUndefinedResult(It.IsAny(), It.IsAny(), It.IsAny()))}, - { ScenarioExecutionStatus.Skipped, (factory => factory.BuildSkippedResult(It.IsAny()))}, - }; - - public static IEnumerable GetTestCases - { - get - { - foreach (var func in _testCases) - { - yield return new object[] {func.Key, func.Value}; - } - } - - } - - [Theory(DisplayName = "Correct method on TestResultPartsFactory is called for ScenarioExecutionStatus")] - [Xunit.MemberData(nameof(GetTestCases))] - - public void BuildFromContext_PassedScenario_TestResultPartFactoryBuildPassedResultIsCalled(ScenarioExecutionStatus scenarioExecutionStatus, Expression> expression) - { - // ARRANGE - var testResultPartsFactoryMock = new Mock(); - var testResultFactory = new TestResultFactory(testResultPartsFactoryMock.Object); - - // ACT - var actualTestResult = testResultFactory.BuildFromContext(CreateScenarioContext(scenarioExecutionStatus), null); - - // ASSERT - testResultPartsFactoryMock.Verify(expression, Times.Once); - } - - [Fact(DisplayName = "Correct method on TestResultPartsFactory is called for failed Scenario")] - public void BuildFromContext_FailedScenario_TestResultPartFactoryBuildPassedResultIsCalled() - { - // ARRANGE - var testResultPartsFactoryMock = new Mock(); - var testResultFactory = new TestResultFactory(testResultPartsFactoryMock.Object); - - // ACT - var actualTestResult = testResultFactory.BuildFromContext(CreateScenarioContext(ScenarioExecutionStatus.OK), null); - - // ASSERT - testResultPartsFactoryMock.Verify(m => m.BuildPassedResult(It.IsAny()), Times.Once); - } - } -} diff --git a/Tests/TechTalk.SpecFlow.RuntimeTests/CucumberMessages/TestResultPartFactoryTestsAmbiguous.cs b/Tests/TechTalk.SpecFlow.RuntimeTests/CucumberMessages/TestResultPartFactoryTestsAmbiguous.cs deleted file mode 100644 index dfcbf28d1..000000000 --- a/Tests/TechTalk.SpecFlow.RuntimeTests/CucumberMessages/TestResultPartFactoryTestsAmbiguous.cs +++ /dev/null @@ -1,58 +0,0 @@ -using System; -using FluentAssertions; -using Io.Cucumber.Messages; -using TechTalk.SpecFlow.CommonModels; -using Xunit; - -namespace TechTalk.SpecFlow.RuntimeTests.CucumberMessages -{ - public class TestResultPartFactoryTestsAmbiguous : TestResultPartFactoryTestsBase - { - [Fact(DisplayName = @"BuildAmbiguousResult should return a TestResult with status Ambiguous")] - public void BuildAmbiguousResult_ValidParameters_ShouldReturnTestResultWithStatusAmbiguous() - { - // ARRANGE - var testResultFactory = GetTestResultPartFactory(); - const TestResult.Types.Status expectedStatus = TestResult.Types.Status.Ambiguous; - - // ACT - var actualTestResult = testResultFactory.BuildAmbiguousResult(10Lu, null); - - // ASSERT - actualTestResult.Should().BeAssignableTo>().Which - .Result.Status.Should().Be(expectedStatus); - } - - [Fact(DisplayName = @"BuildAmbiguousResult should return a TestResult with the passed nanoseconds duration")] - public void BuildAmbiguousResult_Nanoseconds_ShouldReturnTestResultWithNanoseconds() - { - // ARRANGE - var testResultFactory = GetTestResultPartFactory(); - const ulong expectedNanoseconds = 15Lu; - - // ACT - var actualTestResult = testResultFactory.BuildAmbiguousResult(expectedNanoseconds, null); - - // ASSERT - actualTestResult.Should().BeAssignableTo>().Which - .Result.Duration.ToNanoseconds().Should().Be(expectedNanoseconds); - } - - [Fact(DisplayName = @"BuildAmbiguousResult should return a TestResult with the passed message")] - public void BuildAmbiguousResult_Message_ShouldReturnTestResultWithMessage() - { - // ARRANGE - const string expectedMessage = "This is a test message"; - var testResultFactory = GetTestResultPartFactory(expectedMessage: expectedMessage); - - - // ACT - var actualTestResult = testResultFactory.BuildAmbiguousResult(10Lu, null); - - // ASSERT - actualTestResult.Should().BeAssignableTo>().Which - .Result.Message.Should().Be(expectedMessage); - } - - } -} diff --git a/Tests/TechTalk.SpecFlow.RuntimeTests/CucumberMessages/TestResultPartFactoryTestsBase.cs b/Tests/TechTalk.SpecFlow.RuntimeTests/CucumberMessages/TestResultPartFactoryTestsBase.cs deleted file mode 100644 index 8ba0bc7ab..000000000 --- a/Tests/TechTalk.SpecFlow.RuntimeTests/CucumberMessages/TestResultPartFactoryTestsBase.cs +++ /dev/null @@ -1,64 +0,0 @@ -using Moq; -using TechTalk.SpecFlow.CucumberMessages; -using TechTalk.SpecFlow.ErrorHandling; - -namespace TechTalk.SpecFlow.RuntimeTests.CucumberMessages -{ - public class TestResultPartFactoryTestsBase - { - public TestResultPartsFactory GetTestResultPartFactory(string expectedMessage = null) - { - var testResultFactory = new TestResultPartsFactory( - CreateTestErrorMessageFactoryMock(expectedMessage), - CreateTestPendingMessageFactoryMock(expectedMessage), - CreateTestAmbiguousMessageFactoryMock(expectedMessage), - CreateTestUndefiendMessageFactoryMock(expectedMessage)); - return testResultFactory; - } - - private ITestUndefinedMessageFactory CreateTestUndefiendMessageFactoryMock(string expectedMessage) - { - var mock = new Mock(); - mock.Setup(m => m.BuildFromContext(It.IsAny(), It.IsAny())).Returns(() => expectedMessage); - return mock.Object; - } - - private ITestPendingMessageFactory CreateTestPendingMessageFactoryMock(string expectedMessage) - { - var mock = new Mock(); - mock.Setup(m => m.BuildFromScenarioContext(It.IsAny())).Returns(() => expectedMessage); - return mock.Object; - } - - private ITestErrorMessageFactory CreateTestErrorMessageFactoryMock(string expectedMessage) - { - var mock = new Mock(); - mock.Setup(m => m.BuildFromScenarioContext(It.IsAny())).Returns(() => expectedMessage); - - return mock.Object; - } - - private ITestAmbiguousMessageFactory CreateTestAmbiguousMessageFactoryMock(string expectedMessage) - { - var mock = new Mock(); - mock.Setup(m => m.BuildFromScenarioContext(It.IsAny())).Returns(() => expectedMessage); - return mock.Object; - } - - public Mock GetErrorProviderMock() - { - var errorProviderMock = new Mock(); - errorProviderMock.Setup(m => m.GetPendingStepDefinitionError()) - .Returns(new PendingStepException()); - return errorProviderMock; - } - - public Mock GetTestUndefinedMessageFactoryMock() - { - var testUndefinedMessageFactoryMock = new Mock(); - testUndefinedMessageFactoryMock.Setup(m => m.BuildFromContext(It.IsAny(), It.IsAny())) - .Returns("Step definition not defined"); - return testUndefinedMessageFactoryMock; - } - } -} \ No newline at end of file diff --git a/Tests/TechTalk.SpecFlow.RuntimeTests/CucumberMessages/TestResultPartFactoryTestsFailed.cs b/Tests/TechTalk.SpecFlow.RuntimeTests/CucumberMessages/TestResultPartFactoryTestsFailed.cs deleted file mode 100644 index ffe7b2007..000000000 --- a/Tests/TechTalk.SpecFlow.RuntimeTests/CucumberMessages/TestResultPartFactoryTestsFailed.cs +++ /dev/null @@ -1,57 +0,0 @@ -using System; -using FluentAssertions; -using Io.Cucumber.Messages; -using TechTalk.SpecFlow.CommonModels; -using Xunit; - -namespace TechTalk.SpecFlow.RuntimeTests.CucumberMessages -{ - public class TestResultPartFactoryTestsFailed : TestResultPartFactoryTestsBase - { - [Fact(DisplayName = @"BuildFailedResult should return a TestResult with status Failed")] - public void BuildFailedResult_ValidParameters_ShouldReturnTestResultWithStatusFailed() - { - // ARRANGE - var testResultFactory = GetTestResultPartFactory(expectedMessage: "Test Message"); - const TestResult.Types.Status expectedStatus = TestResult.Types.Status.Failed; - - // ACT - var actualTestResult = testResultFactory.BuildFailedResult(10Lu, null); - - // ASSERT - actualTestResult.Should().BeAssignableTo>().Which - .Result.Status.Should().Be(expectedStatus); - } - - [Fact(DisplayName = @"BuildFailedResult should return a TestResult with the passed nanoseconds duration")] - public void BuildFailedResult_Nanoseconds_ShouldReturnTestResultWithNanoseconds() - { - // ARRANGE - var testResultFactory = GetTestResultPartFactory(expectedMessage: "Test Message"); - const ulong expectedNanoseconds = 15Lu; - - // ACT - var actualTestResult = testResultFactory.BuildFailedResult(expectedNanoseconds, null); - - // ASSERT - actualTestResult.Should().BeAssignableTo>().Which - .Result.Duration.ToNanoseconds().Should().Be(expectedNanoseconds); - } - - [Fact(DisplayName = @"BuildFailedResult should return a TestResult with the passed message")] - public void BuildFailedResult_Message_ShouldReturnTestResultWithMessage() - { - // ARRANGE - const string expectedMessage = "This is a test message"; - var testResultFactory = GetTestResultPartFactory(expectedMessage: expectedMessage); - - - // ACT - var actualTestResult = testResultFactory.BuildFailedResult(10Lu, null); - - // ASSERT - actualTestResult.Should().BeAssignableTo>().Which - .Result.Message.Should().Be(expectedMessage); - } - } -} diff --git a/Tests/TechTalk.SpecFlow.RuntimeTests/CucumberMessages/TestResultPartFactoryTestsPassed.cs b/Tests/TechTalk.SpecFlow.RuntimeTests/CucumberMessages/TestResultPartFactoryTestsPassed.cs deleted file mode 100644 index 8902427c2..000000000 --- a/Tests/TechTalk.SpecFlow.RuntimeTests/CucumberMessages/TestResultPartFactoryTestsPassed.cs +++ /dev/null @@ -1,60 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using FluentAssertions; -using Io.Cucumber.Messages; -using TechTalk.SpecFlow.CommonModels; -using Xunit; - -namespace TechTalk.SpecFlow.RuntimeTests.CucumberMessages -{ - public class TestResultPartFactoryTestsPassed : TestResultPartFactoryTestsBase - { - [Fact(DisplayName = @"BuildPassedResult should return a TestResult with status Passed")] - public void BuildPassedResult_ValidParameters_ShouldReturnTestResultWithStatusPassed() - { - // ARRANGE - var testResultFactory = GetTestResultPartFactory(); - const TestResult.Types.Status expectedStatus = TestResult.Types.Status.Passed; - - // ACT - var actualTestResult = testResultFactory.BuildPassedResult(10Lu); - - // ASSERT - actualTestResult.Should().BeAssignableTo>().Which - .Result.Status.Should().Be(expectedStatus); - } - - [Fact(DisplayName = @"BuildPassedResult should return a TestResult with the passed nanoseconds duration")] - public void BuildPassedResult_Nanoseconds_ShouldReturnTestResultWithCorrectNanoseconds() - { - // ARRANGE - var testResultFactory = GetTestResultPartFactory(); - const ulong expectedNanoseconds = 15Lu; - - // ACT - var actualTestResult = testResultFactory.BuildPassedResult(expectedNanoseconds); - - // ASSERT - actualTestResult.Should().BeAssignableTo>().Which - .Result.Duration.ToNanoseconds().Should().Be(expectedNanoseconds); - } - - [Fact(DisplayName = @"BuildPassedResult should return a TestResult with empty message")] - public void BuildPassedResult_ValidParameters_ShouldReturnTestResultWithEmptyMessage() - { - // ARRANGE - var testResultFactory = GetTestResultPartFactory(); - const string expectedMessage = ""; - - // ACT - var actualTestResult = testResultFactory.BuildPassedResult(10Lu); - - // ASSERT - actualTestResult.Should().BeAssignableTo>().Which - .Result.Message.Should().Be(expectedMessage); - } - } -} diff --git a/Tests/TechTalk.SpecFlow.RuntimeTests/CucumberMessages/TestResultPartFactoryTestsPending.cs b/Tests/TechTalk.SpecFlow.RuntimeTests/CucumberMessages/TestResultPartFactoryTestsPending.cs deleted file mode 100644 index 515aa9ced..000000000 --- a/Tests/TechTalk.SpecFlow.RuntimeTests/CucumberMessages/TestResultPartFactoryTestsPending.cs +++ /dev/null @@ -1,57 +0,0 @@ -using System; -using FluentAssertions; -using Io.Cucumber.Messages; -using TechTalk.SpecFlow.CommonModels; -using Xunit; - -namespace TechTalk.SpecFlow.RuntimeTests.CucumberMessages -{ - public class TestResultPartFactoryTestsPending : TestResultPartFactoryTestsBase - { - [Fact(DisplayName = @"BuildPendingResult should return a TestResult with status Pending")] - public void BuildPendingMessage_ValidParameters_ShouldReturnTestResultWithStatusPending() - { - // ARRANGE - var testResultFactory = GetTestResultPartFactory(expectedMessage: "Pending test"); - const TestResult.Types.Status expectedStatus = TestResult.Types.Status.Pending; - - // ACT - var actualTestResult = testResultFactory.BuildPendingResult(10Lu, null); - - // ASSERT - actualTestResult.Should().BeAssignableTo>().Which - .Result.Status.Should().Be(expectedStatus); - } - - [Fact(DisplayName = @"BuildPendingResult should return a TestResult with the passed nanoseconds duration")] - public void BuildPendingResult_Nanoseconds_ShouldReturnTestResultWithNanoseconds() - { - // ARRANGE - var testResultFactory = GetTestResultPartFactory(expectedMessage: "Pending test"); - const ulong expectedNanoseconds = 15Lu; - - // ACT - var actualTestResult = testResultFactory.BuildPendingResult(expectedNanoseconds, null); - - // ASSERT - actualTestResult.Should().BeAssignableTo>().Which - .Result.Duration.ToNanoseconds().Should().Be(expectedNanoseconds); - } - - [Fact(DisplayName = @"BuildPendingResult should return a TestResult with the passed message")] - public void BuildPendingResult_Message_ShouldReturnTestResultWithMessage() - { - // ARRANGE - const string expectedMessage = "This is a test message"; - var testResultFactory = GetTestResultPartFactory(expectedMessage: expectedMessage); - - - // ACT - var actualTestResult = testResultFactory.BuildPendingResult(10Lu, null); - - // ASSERT - actualTestResult.Should().BeAssignableTo>().Which - .Result.Message.Should().Be(expectedMessage); - } - } -} diff --git a/Tests/TechTalk.SpecFlow.RuntimeTests/CucumberMessages/TestResultPartFactoryTestsSkipped.cs b/Tests/TechTalk.SpecFlow.RuntimeTests/CucumberMessages/TestResultPartFactoryTestsSkipped.cs deleted file mode 100644 index d3b944185..000000000 --- a/Tests/TechTalk.SpecFlow.RuntimeTests/CucumberMessages/TestResultPartFactoryTestsSkipped.cs +++ /dev/null @@ -1,55 +0,0 @@ -using System; -using FluentAssertions; -using Io.Cucumber.Messages; -using TechTalk.SpecFlow.CommonModels; -using Xunit; - -namespace TechTalk.SpecFlow.RuntimeTests.CucumberMessages -{ - public class TestResultPartFactoryTestsSkipped : TestResultPartFactoryTestsBase - { - [Fact(DisplayName = @"BuildSkippedResult should return a TestResult with status skipped")] - public void BuildSkippedResult_ValidParameters_ShouldReturnTestResultWithStatusSkipped() - { - // ARRANGE - var testResultFactory = GetTestResultPartFactory(); - const TestResult.Types.Status expectedStatus = TestResult.Types.Status.Skipped; - - // ACT - var actualTestResult = testResultFactory.BuildSkippedResult(10Lu); - - // ASSERT - actualTestResult.Should().BeAssignableTo>().Which - .Result.Status.Should().Be(expectedStatus); - } - - [Fact(DisplayName = @"BuildSkippedResult should return a TestResult with the Skipped nanoseconds duration")] - public void BuildSkippedResult_Nanoseconds_ShouldReturnTestResultWithCorrectNanoseconds() - { - // ARRANGE - var testResultFactory = GetTestResultPartFactory(); - const ulong expectedNanoseconds = 15Lu; - - // ACT - var actualTestResult = testResultFactory.BuildSkippedResult(expectedNanoseconds); - - // ASSERT - actualTestResult.Should().BeAssignableTo>().Which - .Result.Duration.ToNanoseconds().Should().Be(expectedNanoseconds); - } - - [Fact(DisplayName = @"BuildSkippedResult should return a TestResult with empty message")] - public void BuildSkippedResult_ValidParameters_ShouldReturnTestResultWithEmptyMessage() - { - // ARRANGE - var testResultFactory = GetTestResultPartFactory(); - - // ACT - var actualTestResult = testResultFactory.BuildSkippedResult(10Lu); - - // ASSERT - actualTestResult.Should().BeAssignableTo>().Which - .Result.Message.Should().BeEmpty(); - } - } -} diff --git a/Tests/TechTalk.SpecFlow.RuntimeTests/CucumberMessages/TestResultPartFactoryTestsUndefined.cs b/Tests/TechTalk.SpecFlow.RuntimeTests/CucumberMessages/TestResultPartFactoryTestsUndefined.cs deleted file mode 100644 index 1ef823096..000000000 --- a/Tests/TechTalk.SpecFlow.RuntimeTests/CucumberMessages/TestResultPartFactoryTestsUndefined.cs +++ /dev/null @@ -1,58 +0,0 @@ -using System; -using FluentAssertions; -using Io.Cucumber.Messages; -using TechTalk.SpecFlow.CommonModels; -using Xunit; - -namespace TechTalk.SpecFlow.RuntimeTests.CucumberMessages -{ - public class TestResultPartFactoryTestsUndefined : TestResultPartFactoryTestsBase - { - [Fact(DisplayName = @"BuildUndefinedResult should return a TestResult with status Undefined")] - public void BuildUndefinedResult_ValidParameters_ShouldReturnTestResultWithStatusUndefined() - { - // ARRANGE - var testResultFactory = GetTestResultPartFactory(expectedMessage: "Undefined test"); - const TestResult.Types.Status expectedStatus = TestResult.Types.Status.Undefined; - - // ACT - var actualTestResult = testResultFactory.BuildUndefinedResult(10Lu, null, null); - - // ASSERT - actualTestResult.Should().BeAssignableTo>().Which - .Result.Status.Should().Be(expectedStatus); - } - - [Fact(DisplayName = @"BuildUndefinedResult should return a TestResult with the passed nanoseconds duration")] - public void BuildUndefinedResult_Nanoseconds_ShouldReturnTestResultWithNanoseconds() - { - // ARRANGE - var testResultFactory = GetTestResultPartFactory(expectedMessage: "Undefined test"); - const ulong expectedNanoseconds = 15Lu; - - // ACT - var actualTestResult = testResultFactory.BuildUndefinedResult(expectedNanoseconds, null, null); - - // ASSERT - actualTestResult.Should().BeAssignableTo>().Which - .Result.Duration.ToNanoseconds().Should().Be(expectedNanoseconds); - } - - [Fact(DisplayName = @"BuildUndefinedResult should return a TestResult with the passed message")] - public void BuildUndefinedResult_Message_ShouldReturnTestResultWithMessage() - { - // ARRANGE - const string expectedMessage = "This is a test message"; - var testResultFactory = GetTestResultPartFactory(expectedMessage: expectedMessage); - - - // ACT - var actualTestResult = testResultFactory.BuildUndefinedResult(10Lu, null, null); - - // ASSERT - actualTestResult.Should().BeAssignableTo>().Which - .Result.Message.Should().Be(expectedMessage); - } - - } -} diff --git a/Tests/TechTalk.SpecFlow.RuntimeTests/CucumberMessages/TimestampExtensions.cs b/Tests/TechTalk.SpecFlow.RuntimeTests/CucumberMessages/TimestampExtensions.cs deleted file mode 100644 index 22377ea5c..000000000 --- a/Tests/TechTalk.SpecFlow.RuntimeTests/CucumberMessages/TimestampExtensions.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; -using Io.Cucumber.Messages; - -namespace TechTalk.SpecFlow.RuntimeTests.CucumberMessages -{ - public static class TimestampExtensions - { - private static readonly DateTime UnixEpochStart = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc); - - public static DateTime ToDateTime(this Timestamp timestamp) - { - return UnixEpochStart.AddSeconds(timestamp.Seconds); - } - - public static ulong ToNanoseconds(this Duration duration) - { - return (ulong)(duration.Seconds * 1_000_000_000 + duration.Nanos); - } - } -} \ No newline at end of file diff --git a/Tests/TechTalk.SpecFlow.RuntimeTests/Infrastructure/TestExecutionEngineTests.cs b/Tests/TechTalk.SpecFlow.RuntimeTests/Infrastructure/TestExecutionEngineTests.cs index 6b5906553..374ef61dd 100644 --- a/Tests/TechTalk.SpecFlow.RuntimeTests/Infrastructure/TestExecutionEngineTests.cs +++ b/Tests/TechTalk.SpecFlow.RuntimeTests/Infrastructure/TestExecutionEngineTests.cs @@ -16,7 +16,6 @@ using TechTalk.SpecFlow.UnitTestProvider; using FluentAssertions; using TechTalk.SpecFlow.Analytics; -using TechTalk.SpecFlow.CucumberMessages; using TechTalk.SpecFlow.Events; using TechTalk.SpecFlow.Plugins; @@ -36,7 +35,6 @@ public partial class TestExecutionEngineTests private Mock stepDefinitionSkeletonProviderMock; private Mock testObjectResolverMock; private Mock obsoleteTestHandlerMock; - private Mock cucumberMessageSenderMock; private FeatureInfo featureInfo; private ScenarioInfo scenarioInfo; private ObjectContainer testThreadContainer; @@ -137,9 +135,7 @@ public TestExecutionEngineTests() obsoleteTestHandlerMock = new Mock(); - cucumberMessageSenderMock = new Mock(); - cucumberMessageSenderMock.Setup(m => m.SendTestRunStarted()) - .Callback(() => { }); + _testPendingMessageFactory = new TestPendingMessageFactory(errorProviderStub.Object); _testUndefinedMessageFactory = new TestUndefinedMessageFactory(stepDefinitionSkeletonProviderMock.Object, errorProviderStub.Object, specFlowConfiguration); @@ -172,38 +168,17 @@ private TestExecutionEngine CreateTestExecutionEngine() stepDefinitionMatcherStub.Object, methodBindingInvokerMock.Object, obsoleteTestHandlerMock.Object, - cucumberMessageSenderMock.Object, - new TestResultFactory(new TestResultPartsFactory(new TestErrorMessageFactory(), _testPendingMessageFactory, new TestAmbiguousMessageFactory(), _testUndefinedMessageFactory)), - _testPendingMessageFactory, - _testUndefinedMessageFactory, - new Mock().Object, _analyticsEventProvider.Object, _analyticsTransmitter.Object, _testRunnerManager.Object, _runtimePluginTestExecutionLifecycleEventEmitter.Object, _testThreadExecutionEventPublisher.Object, + _testPendingMessageFactory, + _testUndefinedMessageFactory, testObjectResolverMock.Object, testThreadContainer); } - private Mock GetPickleIdStoreMock() - { - var dictionary = new Dictionary(); - var pickleIdStoreMock = new Mock(); - pickleIdStoreMock.Setup(m => m.GetPickleIdForScenario(It.IsAny())) - .Returns(info => - { - if (dictionary.ContainsKey(info)) - { - return dictionary[info]; - } - - var newGuid = Guid.NewGuid(); - dictionary.Add(info, newGuid); - return newGuid; - }); - return pickleIdStoreMock; - } private Mock RegisterStepDefinition() { diff --git a/Tests/TechTalk.SpecFlow.Specs/Drivers/ConfigurationLoaderDriver.cs b/Tests/TechTalk.SpecFlow.Specs/Drivers/ConfigurationLoaderDriver.cs index 6f0c9e1aa..288d3e474 100644 --- a/Tests/TechTalk.SpecFlow.Specs/Drivers/ConfigurationLoaderDriver.cs +++ b/Tests/TechTalk.SpecFlow.Specs/Drivers/ConfigurationLoaderDriver.cs @@ -7,13 +7,11 @@ namespace TechTalk.SpecFlow.Specs.Drivers public class ConfigurationLoaderDriver { private readonly ConfigurationDriver _configurationDriver; - private readonly CucumberMessagesConfigurationDriver _cucumberMessagesConfigurationDriver; private readonly SolutionDriver _solutionDriver; - public ConfigurationLoaderDriver(ConfigurationDriver configurationDriver, CucumberMessagesConfigurationDriver cucumberMessagesConfigurationDriver, SolutionDriver solutionDriver) + public ConfigurationLoaderDriver(ConfigurationDriver configurationDriver, SolutionDriver solutionDriver) { _configurationDriver = configurationDriver; - _cucumberMessagesConfigurationDriver = cucumberMessagesConfigurationDriver; _solutionDriver = solutionDriver; } @@ -28,7 +26,6 @@ public void SetFromSpecFlowConfiguration(SpecFlowConfiguration specFlowConfigura _configurationDriver.SetBindingCulture(project, specFlowConfiguration.BindingCulture); _configurationDriver.SetFeatureLanguage(project, specFlowConfiguration.FeatureLanguage); - _cucumberMessagesConfigurationDriver.SetEnabled(project, specFlowConfiguration.CucumberMessagesConfiguration.Enabled); } } } diff --git a/Tests/TechTalk.SpecFlow.Specs/Drivers/CucumberMessages/MessageValidationDriver.cs b/Tests/TechTalk.SpecFlow.Specs/Drivers/CucumberMessages/MessageValidationDriver.cs deleted file mode 100644 index 86e3e2bee..000000000 --- a/Tests/TechTalk.SpecFlow.Specs/Drivers/CucumberMessages/MessageValidationDriver.cs +++ /dev/null @@ -1,64 +0,0 @@ -using System.Linq; -using TechTalk.SpecFlow.Assist; -using TechTalk.SpecFlow.TestProjectGenerator.CucumberMessages; -using TechTalk.SpecFlow.TestProjectGenerator.CucumberMessages.RowObjects; - -namespace TechTalk.SpecFlow.Specs.Drivers.CucumberMessages -{ - public class MessageValidationDriver - { - private readonly TestCaseFinishedDriver _testCaseFinishedDriver; - private readonly TestRunStartedDriver _testRunStartedDriver; - private readonly TestCaseStartedDriver _testCaseStartedDriver; - - public MessageValidationDriver(TestCaseFinishedDriver testCaseFinishedDriver, TestRunStartedDriver testRunStartedDriver, TestCaseStartedDriver testCaseStartedDriver) - { - _testCaseFinishedDriver = testCaseFinishedDriver; - _testRunStartedDriver = testRunStartedDriver; - _testCaseStartedDriver = testCaseStartedDriver; - } - - public void TestCaseFinishedMessageShouldHaveBeenSent(Table values) - { - var testCaseFinishedRow = values.CreateInstance(); - _testCaseFinishedDriver.TestCaseFinishedMessageShouldHaveBeenSent(testCaseFinishedRow); - } - - public void TestCaseFinishedMessageShouldHaveBeenSentWithTestResult(Table values) - { - var testResultRow = values.CreateInstance(); - _testCaseFinishedDriver.TestCaseFinishedMessageShouldHaveBeenSentWithTestResult(testResultRow); - } - - public void TestRunStartedMessageShouldHaveBeenSent(Table values) - { - var testRunStartedRow = values.CreateInstance(); - _testRunStartedDriver.TestRunStartedMessageShouldHaveBeenSent(testRunStartedRow); - } - - public void TestCaseStartedMessageShouldHaveBeenSent(Table values) - { - var testCaseStartedRow = values.CreateInstance(); - _testCaseStartedDriver.TestCaseStartedMessageShouldHaveBeenSent(testCaseStartedRow); - } - - public void TestCaseStartedMessageShouldHaveBeenSentWithPlatformInformation(Table values) - { - var platformRow = values.CreateInstance(); - _testCaseStartedDriver.TestCaseStartedMessageShouldHaveBeenSentWithPlatformInformation(platformRow); - } - - public void TestCaseStartedMessageShouldHaveBeenSentWithPlatformInformationAttributes(Table attributes) - { - var expectedAttributes = attributes.Rows.Select(r => r["Attribute"]); - _testCaseStartedDriver.TestCaseStartedMessageShouldHaveBeenSentWithPlatformInformationAttributes(expectedAttributes); - } - - public void TestRunFinishedMessageShouldHaveBeenSent(Table values) - { - var testRunFinishedRow = values.CreateInstance(); - _testRunStartedDriver.TestRunFinishedMessageShouldHaveBeenSent(testRunFinishedRow); - - } - } -} diff --git a/Tests/TechTalk.SpecFlow.Specs/Features/Configuration/Cucumber-Messages App.Config Configuration.feature b/Tests/TechTalk.SpecFlow.Specs/Features/Configuration/Cucumber-Messages App.Config Configuration.feature deleted file mode 100644 index 10b2a3eac..000000000 --- a/Tests/TechTalk.SpecFlow.Specs/Features/Configuration/Cucumber-Messages App.Config Configuration.feature +++ /dev/null @@ -1,81 +0,0 @@ -@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 - """ - - - -
- - - - - - - """ - 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 - """ - - - -
- - - - - - - """ - 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 - """ - - - -
- - - - - - - """ - 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 - """ - - - -
- - - - - - - - - - - """ - When the test suite is executed - Then the Cucumber-Messages file 'custom_cucumber_messages_file.cm' is created - diff --git a/Tests/TechTalk.SpecFlow.Specs/Features/Configuration/Cucumber-Messages Json Configuration.feature b/Tests/TechTalk.SpecFlow.Specs/Features/Configuration/Cucumber-Messages Json Configuration.feature deleted file mode 100644 index 71822bb45..000000000 --- a/Tests/TechTalk.SpecFlow.Specs/Features/Configuration/Cucumber-Messages Json Configuration.feature +++ /dev/null @@ -1,61 +0,0 @@ -Feature: Cucumber-Messages Configuration via specflow.json - - Cucumber-messages can be configured in the specflow.json file to enable/disable messages - and configure alternative output sinks - -Scenario: No configuration creates no output file - - Given there is a project with this specflow.json configuration - """ - { - "cucumber-messages": - { - } - } - """ - 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 specflow.json configuration - """ - { - "cucumber-messages": - { - "enabled": false - } - } - """ - 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 specflow.json configuration - """ - { - "cucumber-messages": - { - "enabled": true - } - } - """ - 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 specflow.json configuration - """ - { - "cucumber-messages": - { - "enabled": true, - "sinks": [ - { "type":"file", "path": "custom_cucumber_messages_file.cm" } - ] - } - } - """ - When the test suite is executed - Then the Cucumber-Messages file 'custom_cucumber_messages_file.cm' is created diff --git a/Tests/TechTalk.SpecFlow.Specs/Features/Configuration/No Configuration.feature b/Tests/TechTalk.SpecFlow.Specs/Features/Configuration/No Configuration.feature deleted file mode 100644 index 3589c10cc..000000000 --- a/Tests/TechTalk.SpecFlow.Specs/Features/Configuration/No Configuration.feature +++ /dev/null @@ -1,10 +0,0 @@ -Feature: No Configuration - - -Scenario: No configuration file creates no cucumber-message output file - - Given the project has no specflow.json configuration - And the project has no app.config configuration - - When the test suite is executed - Then no Cucumber-Messages file is created \ No newline at end of file diff --git a/Tests/TechTalk.SpecFlow.Specs/Features/Hooks/ScopedHooks.feature b/Tests/TechTalk.SpecFlow.Specs/Features/Hooks/ScopedHooks.feature index cb42b9cbf..f34501c9f 100644 --- a/Tests/TechTalk.SpecFlow.Specs/Features/Hooks/ScopedHooks.feature +++ b/Tests/TechTalk.SpecFlow.Specs/Features/Hooks/ScopedHooks.feature @@ -34,7 +34,7 @@ Scenario: Two hooks for the same event are called once each And the hook 'Hook2' is executed once -Scenario: Two hooks for diffenrent events are called once each +Scenario: Two hooks for different events are called once each Given there is a feature file in the project as """ Feature: Simple Feature diff --git a/Tests/TechTalk.SpecFlow.Specs/StepDefinitions/CucumberMessages/CucumberMessagesFileSteps.cs b/Tests/TechTalk.SpecFlow.Specs/StepDefinitions/CucumberMessages/CucumberMessagesFileSteps.cs deleted file mode 100644 index b438a7808..000000000 --- a/Tests/TechTalk.SpecFlow.Specs/StepDefinitions/CucumberMessages/CucumberMessagesFileSteps.cs +++ /dev/null @@ -1,27 +0,0 @@ -using TechTalk.SpecFlow.TestProjectGenerator.CucumberMessages; - -namespace TechTalk.SpecFlow.Specs.StepDefinitions.CucumberMessages -{ - [Binding] - public class CucumberMessagesFileSteps - { - private readonly CucumberMessagesFileDriver _cucumberMessagesFileDriver; - - public CucumberMessagesFileSteps(CucumberMessagesFileDriver cucumberMessagesFileDriver) - { - _cucumberMessagesFileDriver = cucumberMessagesFileDriver; - } - - [Then(@"no Cucumber-Messages file is created")] - public void ThenNoCucumber_MessagesFileIsCreated() - { - _cucumberMessagesFileDriver.CucumberMessagesFileShouldNotExist(); - } - - [Then(@"the Cucumber-Messages file '(.*)' is created")] - public void ThenTheCucumber_MessagesFileIsCreated(string expectedCucumberMessagesFile) - { - _cucumberMessagesFileDriver.CucumberMessagesFileShouldBe(expectedCucumberMessagesFile); - } - } -} diff --git a/Tests/TechTalk.SpecFlow.Specs/StepDefinitions/CucumberMessages/ScenarioSteps.cs b/Tests/TechTalk.SpecFlow.Specs/StepDefinitions/CucumberMessages/ScenarioSteps.cs deleted file mode 100644 index 21a61c9ed..000000000 --- a/Tests/TechTalk.SpecFlow.Specs/StepDefinitions/CucumberMessages/ScenarioSteps.cs +++ /dev/null @@ -1,80 +0,0 @@ -using System; -using TechTalk.SpecFlow.Assist; -using TechTalk.SpecFlow.TestProjectGenerator.CucumberMessages; -using TechTalk.SpecFlow.TestProjectGenerator.CucumberMessages.RowObjects; -using TechTalk.SpecFlow.TestProjectGenerator.Driver; - -namespace TechTalk.SpecFlow.Specs.StepDefinitions.CucumberMessages -{ - [Binding] - public class ScenarioSteps - { - private readonly TestSuiteSetupDriver _testSuiteSetupDriver; - private readonly ProjectsDriver _projectsDriver; - - public ScenarioSteps(TestSuiteSetupDriver testSuiteSetupDriver, ProjectsDriver projectsDriver) - { - _testSuiteSetupDriver = testSuiteSetupDriver; - _projectsDriver = projectsDriver; - } - - [Given(@"there are '(\d+)' scenarios")] - [Given(@"there are (\d+) scenarios")] - public void GivenThereAreScenarios(int scenarios) - { - _testSuiteSetupDriver.AddScenarios(scenarios); - } - - [Given(@"there is a scenario")] - public void GivenThereIsAScenario() - { - _testSuiteSetupDriver.AddScenarios(1); - } - - [Given(@"there is a scenario with PickleId '(.*)'")] - public void GivenThereIsAScenarioWithPickleId(Guid pickleId) - { - _testSuiteSetupDriver.AddScenario(pickleId); - } - - [Given(@"there are two step definitions with identical bindings")] - public void GivenThereAreTwoStepDefinitionsWithIdenticalRegex() - { - _testSuiteSetupDriver.AddDuplicateStepDefinition("When", "the step pass in .*"); - } - - [Given(@"there are no matching step definitions")] - public void GivenThereAreNoMatchingStepDefinitions() - { - _testSuiteSetupDriver.AddNotMatchingStepDefinition(); - } - - [Given(@"there is a scenario with the following steps: '(.*)'")] - public void GivenThereIsAScenarioWithTheFollowingSteps(string step) - { - _testSuiteSetupDriver.AddScenarioWithGivenStep(step); - } - - [Given(@"with step definitions in the following order: '(.*)'")] - public void GivenWithStepDefinitionsInTheFollowingOrder(string stepDefinitionOrder) - { - _testSuiteSetupDriver.AddStepDefinitionsFromStringList(stepDefinitionOrder); - } - - [Given(@"there is an ignored scenario with the following steps: '(.*)'")] - public void GivenThereIsAnIgnoredScenarioWithTheFollowingSteps(string step) - { - _testSuiteSetupDriver.AddScenarioWithGivenStep(step, "@ignore"); - } - - [Given(@"there are following scenarios:")] - public void GivenThereAreFollowingScenarios(Table table) - { - var createScenarioWithResultRows = table.CreateInstance(); - - _testSuiteSetupDriver.AddScenarios(createScenarioWithResultRows); - - } - - } -} diff --git a/Tests/TechTalk.SpecFlow.Specs/StepDefinitions/CucumberMessages/TestCaseFinishedSteps.cs b/Tests/TechTalk.SpecFlow.Specs/StepDefinitions/CucumberMessages/TestCaseFinishedSteps.cs deleted file mode 100644 index f9f40757b..000000000 --- a/Tests/TechTalk.SpecFlow.Specs/StepDefinitions/CucumberMessages/TestCaseFinishedSteps.cs +++ /dev/null @@ -1,58 +0,0 @@ -using System; -using TechTalk.SpecFlow.Specs.Drivers; -using TechTalk.SpecFlow.Specs.Drivers.CucumberMessages; -using TechTalk.SpecFlow.TestProjectGenerator.CucumberMessages; -using TechTalk.SpecFlow.TestProjectGenerator.Driver; - -namespace TechTalk.SpecFlow.Specs.StepDefinitions.CucumberMessages -{ - [Binding] - public class TestCaseFinishedSteps - { - private readonly TestSuiteInitializationDriver _testSuiteInitializationDriver; - private readonly TestSuiteSetupDriver _testSuiteSetupDriver; - private readonly TestCaseFinishedDriver _testCaseFinishedDriver; - private readonly MessageValidationDriver _messageValidationDriver; - private readonly ExecutionDriver _executionDriver; - - public TestCaseFinishedSteps( - TestSuiteInitializationDriver testSuiteInitializationDriver, - TestSuiteSetupDriver testSuiteSetupDriver, - TestCaseFinishedDriver testCaseFinishedDriver, - MessageValidationDriver messageValidationDriver, - ExecutionDriver executionDriver) - { - _testSuiteInitializationDriver = testSuiteInitializationDriver; - _testSuiteSetupDriver = testSuiteSetupDriver; - _testCaseFinishedDriver = testCaseFinishedDriver; - _messageValidationDriver = messageValidationDriver; - _executionDriver = executionDriver; - } - - [When(@"the scenario is finished at '(.*)'")] - public void WhenTheScenarioIsFinishedAt(DateTime finishTime) - { - _testSuiteInitializationDriver.OverrideTestCaseFinishedTime = finishTime; - _testSuiteSetupDriver.EnsureAProjectIsCreated(); - _executionDriver.ExecuteTests(); - } - - [Then(@"(.*) TestCaseFinished messages have been sent")] - public void ThenTestCaseFinishedMessagesHaveBeenSent(int numberOfMessages) - { - _testCaseFinishedDriver.TestCaseFinishedMessagesShouldHaveBeenSent(numberOfMessages); - } - - [Then(@"a TestCaseFinished message has been sent with the following attributes")] - public void ThenATestCaseFinishedMessageHasBeenSentWithTheFollowingAttributes(Table table) - { - _messageValidationDriver.TestCaseFinishedMessageShouldHaveBeenSent(table); - } - - [Then(@"a TestCaseFinished message has been sent with the following TestResult")] - public void ThenATestCaseFinishedMessageHasBeenSentWithTheFollowingTestResult(Table table) - { - _messageValidationDriver.TestCaseFinishedMessageShouldHaveBeenSentWithTestResult(table); - } - } -} diff --git a/Tests/TechTalk.SpecFlow.Specs/StepDefinitions/CucumberMessages/TestCaseStartedSteps.cs b/Tests/TechTalk.SpecFlow.Specs/StepDefinitions/CucumberMessages/TestCaseStartedSteps.cs deleted file mode 100644 index 4a95a123d..000000000 --- a/Tests/TechTalk.SpecFlow.Specs/StepDefinitions/CucumberMessages/TestCaseStartedSteps.cs +++ /dev/null @@ -1,71 +0,0 @@ -using System; -using TechTalk.SpecFlow.Specs.Drivers; -using TechTalk.SpecFlow.Specs.Drivers.CucumberMessages; -using TechTalk.SpecFlow.TestProjectGenerator.CucumberMessages; -using TechTalk.SpecFlow.TestProjectGenerator.Driver; - -namespace TechTalk.SpecFlow.Specs.StepDefinitions.CucumberMessages -{ - [Binding] - public class TestCaseStartedSteps - { - private readonly TestCaseStartedDriver _testCaseStartedDriver; - private readonly TestSuiteInitializationDriver _testSuiteInitializationDriver; - private readonly TestSuiteSetupDriver _testSuiteSetupDriver; - private readonly MessageValidationDriver _messageValidationDriver; - private readonly ExecutionDriver _executionDriver; - - public TestCaseStartedSteps( - TestCaseStartedDriver testCaseStartedDriver, - TestSuiteInitializationDriver testSuiteInitializationDriver, - TestSuiteSetupDriver testSuiteSetupDriver, - MessageValidationDriver messageValidationDriver, - ExecutionDriver executionDriver) - { - _testCaseStartedDriver = testCaseStartedDriver; - _testSuiteInitializationDriver = testSuiteInitializationDriver; - _testSuiteSetupDriver = testSuiteSetupDriver; - _messageValidationDriver = messageValidationDriver; - _executionDriver = executionDriver; - } - - [When(@"the scenario is executed")] - public void WhenTheScenarioIsExecuted() - { - _testSuiteSetupDriver.EnsureAProjectIsCreated(); - _executionDriver.ExecuteTests(); - } - - [When(@"the scenario is started at '(.*)'")] - public void WhenTheScenarioIsStartedAt(DateTime startTime) - { - _testSuiteInitializationDriver.OverrideTestCaseStartedTime = startTime; - _testSuiteSetupDriver.EnsureAProjectIsCreated(); - _executionDriver.ExecuteTests(); - } - - [Then(@"'(\d+)' TestCaseStarted messages have been sent")] - public void ThenTestCaseStartedMessagesHaveBeenSent(int numberOfTestCaseStartedMessages) - { - _testCaseStartedDriver.TestCaseStartedMessagesShouldHaveBeenSent(numberOfTestCaseStartedMessages); - } - - [Then(@"a TestCaseStarted message has been sent with the following attributes")] - public void ThenATestCaseStartedMessageHasBeenSentWithTheFollowingAttributes(Table table) - { - _messageValidationDriver.TestCaseStartedMessageShouldHaveBeenSent(table); - } - - [Then(@"a TestCaseStarted message has been sent with the following platform information")] - public void ThenATestCaseStartedMessageHasBeenSentWithTheFollowingPlatformInformation(Table table) - { - _messageValidationDriver.TestCaseStartedMessageShouldHaveBeenSentWithPlatformInformation(table); - } - - [Then(@"the TestCaseStarted message contains the following platform information attributes")] - public void ThenTheTestCaseStartedMessageContainsTheFollowingPlatformInformationAttributes(Table attributes) - { - _messageValidationDriver.TestCaseStartedMessageShouldHaveBeenSentWithPlatformInformationAttributes(attributes); - } - } -} diff --git a/Tests/TechTalk.SpecFlow.Specs/StepDefinitions/CucumberMessages/TestRunFinishedSteps.cs b/Tests/TechTalk.SpecFlow.Specs/StepDefinitions/CucumberMessages/TestRunFinishedSteps.cs deleted file mode 100644 index a94a90d0b..000000000 --- a/Tests/TechTalk.SpecFlow.Specs/StepDefinitions/CucumberMessages/TestRunFinishedSteps.cs +++ /dev/null @@ -1,40 +0,0 @@ -using System.Linq; -using TechTalk.SpecFlow.Specs.Drivers.CucumberMessages; -using TechTalk.SpecFlow.TestProjectGenerator.CucumberMessages; - -namespace TechTalk.SpecFlow.Specs.StepDefinitions.CucumberMessages -{ - [Binding] - public class TestRunFinishedSteps - { - private readonly MessageValidationDriver _messageValidationDriver; - private readonly ScenarioContext _scenarioContext; - private readonly TestRunFinishedDriver _testRunFinishedDriver; - - public TestRunFinishedSteps(MessageValidationDriver messageValidationDriver, ScenarioContext scenarioContext, TestRunFinishedDriver testRunFinishedDriver) - { - _messageValidationDriver = messageValidationDriver; - _scenarioContext = scenarioContext; - _testRunFinishedDriver = testRunFinishedDriver; - } - - [Then(@"a TestRunFinished message has been sent with the following attributes")] - public void ThenATestRunFinishedMessageHasBeenSentWithTheFollowingAttributes(Table attributesTable) - { - _messageValidationDriver.TestRunFinishedMessageShouldHaveBeenSent(attributesTable); - } - - - [Then(@"'(.*)' TestRunFinished messages have been sent")] - public void ThenTestRunFinishedMessagesHaveBeenSent(int numberOfMessages) - { - if (_scenarioContext.ScenarioInfo.Tags.Contains("SpecFlow")) - { - return; - } - - _testRunFinishedDriver.TestRunFinishedMessageShouldHaveBeenSent(numberOfMessages); - } - - } -} \ No newline at end of file diff --git a/Tests/TechTalk.SpecFlow.Specs/StepDefinitions/CucumberMessages/TestRunStartedSteps.cs b/Tests/TechTalk.SpecFlow.Specs/StepDefinitions/CucumberMessages/TestRunStartedSteps.cs deleted file mode 100644 index be1740ef3..000000000 --- a/Tests/TechTalk.SpecFlow.Specs/StepDefinitions/CucumberMessages/TestRunStartedSteps.cs +++ /dev/null @@ -1,68 +0,0 @@ -using System; -using System.Linq; -using TechTalk.SpecFlow.Specs.Drivers; -using TechTalk.SpecFlow.Specs.Drivers.CucumberMessages; -using TechTalk.SpecFlow.TestProjectGenerator.CucumberMessages; -using TechTalk.SpecFlow.TestProjectGenerator.Driver; - -namespace TechTalk.SpecFlow.Specs.StepDefinitions.CucumberMessages -{ - [Binding] - public class TestRunStartedSteps - { - private readonly TestRunStartedDriver _testRunStartedDriver; - private readonly TestSuiteSetupDriver _testSuiteSetupDriver; - private readonly TestSuiteInitializationDriver _testSuiteInitializationDriver; - private readonly MessageValidationDriver _messageValidationDriver; - private readonly ScenarioContext _scenarioContext; - private readonly ExecutionDriver _executionDriver; - - public TestRunStartedSteps( - TestRunStartedDriver testRunStartedDriver, - TestSuiteSetupDriver testSuiteSetupDriver, - TestSuiteInitializationDriver testSuiteInitializationDriver, - MessageValidationDriver messageValidationDriver, - ScenarioContext scenarioContext, - ExecutionDriver executionDriver) - { - _testRunStartedDriver = testRunStartedDriver; - _testSuiteSetupDriver = testSuiteSetupDriver; - _testSuiteInitializationDriver = testSuiteInitializationDriver; - _messageValidationDriver = messageValidationDriver; - _scenarioContext = scenarioContext; - _executionDriver = executionDriver; - } - - [When(@"the test suite is executed")] - public void WhenTheTestSuiteIsExecuted() - { - _testSuiteSetupDriver.EnsureAProjectIsCreated(); - _executionDriver.ExecuteTests(); - } - - [When(@"the test suite is started at '(.*)'")] - public void WhenTheTestSuiteIsStartedAt(DateTime startTime) - { - _testSuiteInitializationDriver.OverrideTestSuiteStartupTime = startTime; - _testSuiteSetupDriver.EnsureAProjectIsCreated(); - _executionDriver.ExecuteTests(); - } - - [Then(@"'(\d+)' TestRunStarted messages have been sent")] - public void ThenATestRunStartedMessageHasBeenSent(int numberOfMessages) - { - if (_scenarioContext.ScenarioInfo.Tags.Contains("SpecFlow")) - { - return; - } - - _testRunStartedDriver.TestRunStartedMessageShouldHaveBeenSent(numberOfMessages); - } - - [Then(@"a TestRunStarted message has been sent with the following attributes")] - public void ThenATestRunStartedMessageHasBeenSentWithTheFollowingAttributes(Table attributesTable) - { - _messageValidationDriver.TestRunStartedMessageShouldHaveBeenSent(attributesTable); - } - } -} diff --git a/Tests/TechTalk.SpecFlow.Specs/StepDefinitions/CucumberMessages/TestSuiteSteps.cs b/Tests/TechTalk.SpecFlow.Specs/StepDefinitions/CucumberMessages/TestSuiteSteps.cs deleted file mode 100644 index 3c14f544b..000000000 --- a/Tests/TechTalk.SpecFlow.Specs/StepDefinitions/CucumberMessages/TestSuiteSteps.cs +++ /dev/null @@ -1,62 +0,0 @@ -using System.Linq; -using TechTalk.SpecFlow.TestProjectGenerator.CucumberMessages; - -namespace TechTalk.SpecFlow.Specs.StepDefinitions.CucumberMessages -{ - [Binding] - public class TestSuiteSteps - { - private readonly TestSuiteSetupDriver _testSuiteSetupDriver; - private readonly ScenarioContext _scenarioContext; - - public TestSuiteSteps(TestSuiteSetupDriver testSuiteSetupDriver, ScenarioContext scenarioContext) - { - _testSuiteSetupDriver = testSuiteSetupDriver; - _scenarioContext = scenarioContext; - } - - [Given(@"there are '(\d+)' feature files")] - [Given(@"there are (\d+) feature files")] - public void GivenThereAreFeatureFiles(int featureFilesCount) - { - if (_scenarioContext.ScenarioInfo.Tags.Contains("SpecFlow")) - { - return; - } - - _testSuiteSetupDriver.AddFeatureFiles(featureFilesCount); - } - - - - [Given(@"the cucumber implementation '(.*)'")] - public void GivenTheCucumberImplementationIs(string cucumberImplementation) - { - if (_scenarioContext.ScenarioInfo.Tags.Contains("SpecFlow")) - { - return; - } - - _testSuiteSetupDriver.AddFeatureFiles(1); - _testSuiteSetupDriver.AddGenericWhenStepBinding(); - } - - - - [Given(@"the test runner is '(.*)'")] - [Scope(Tag = "SpecFlow")] - public void GivenTheTestRunnerIs(string testRunner) - { - - } - - [When(@"the test suite is executed with a testThreadCount of '(.*)'")] - [Scope(Tag = "SpecFlow")] - public void WhenTheTestSuiteIsExecutedWithATestThreadCountOf(int p0) - { - - } - - - } -} diff --git a/Tests/TechTalk.SpecFlow.Specs/StepDefinitions/SpecFlowConfigurationSteps.cs b/Tests/TechTalk.SpecFlow.Specs/StepDefinitions/SpecFlowConfigurationSteps.cs index 1fa717304..2a0590eac 100644 --- a/Tests/TechTalk.SpecFlow.Specs/StepDefinitions/SpecFlowConfigurationSteps.cs +++ b/Tests/TechTalk.SpecFlow.Specs/StepDefinitions/SpecFlowConfigurationSteps.cs @@ -1,6 +1,5 @@ using TechTalk.SpecFlow.Specs.Drivers; using TechTalk.SpecFlow.TestProjectGenerator; -using TechTalk.SpecFlow.TestProjectGenerator.CucumberMessages; using TechTalk.SpecFlow.TestProjectGenerator.Driver; namespace TechTalk.SpecFlow.Specs.StepDefinitions @@ -10,20 +9,17 @@ public class SpecFlowConfigurationSteps { private readonly ConfigurationDriver _configurationDriver; private readonly XmlConfigurationParserDriver _xmlConfigurationParserDriver; - private readonly JsonConfigurationLoaderDriver _jsonConfigurationLoaderDriver; private readonly ConfigurationLoaderDriver _configurationLoaderDriver; private readonly TestSuiteSetupDriver _testSuiteSetupDriver; public SpecFlowConfigurationSteps( ConfigurationDriver configurationDriver, XmlConfigurationParserDriver xmlConfigurationParserDriver, - JsonConfigurationLoaderDriver jsonConfigurationLoaderDriver, ConfigurationLoaderDriver configurationLoaderDriver, TestSuiteSetupDriver testSuiteSetupDriver) { _configurationDriver = configurationDriver; _xmlConfigurationParserDriver = xmlConfigurationParserDriver; - _jsonConfigurationLoaderDriver = jsonConfigurationLoaderDriver; _configurationLoaderDriver = configurationLoaderDriver; _testSuiteSetupDriver = testSuiteSetupDriver; } @@ -100,5 +96,11 @@ public void GivenTheTypeIsRegisteredAsInSpecFlowRuntimeConfiguration(string type { _configurationDriver.AddRuntimeRegisterDependency(typeName, interfaceName); } + + [Given(@"there is a scenario")] + public void GivenThereIsAScenario() + { + _testSuiteSetupDriver.AddScenarios(1); + } } } diff --git a/Tests/TechTalk.SpecFlow.Specs/TechTalk.SpecFlow.Specs.csproj b/Tests/TechTalk.SpecFlow.Specs/TechTalk.SpecFlow.Specs.csproj index 1bb0a6703..99d126297 100644 --- a/Tests/TechTalk.SpecFlow.Specs/TechTalk.SpecFlow.Specs.csproj +++ b/Tests/TechTalk.SpecFlow.Specs/TechTalk.SpecFlow.Specs.csproj @@ -37,10 +37,6 @@ - - - - @@ -75,19 +71,6 @@ - - - - <_CucumberMessagesSpecFlowFeatureFiles Include="Features/CucumberMessages/*.feature" /> - - <_CucumberMessagesSpecFlowFeatureFiles> - Features/CucumberMessages/%(Filename).feature$(DefaultLanguageSourceExtension) - $(UsingMicrosoftNETSdk) - - - - - @@ -100,13 +83,6 @@ - - - Always - - - - <_SpecFlow_TaskAssembly>..\..\SpecFlow.Tools.MsBuild.Generation\bin\$(Configuration)\$(_SpecFlow_Needed_MSBuildGenerator)\SpecFlow.Tools.MsBuild.Generation.dll diff --git a/Tests/TechTalk.SpecFlow.Specs/specflow.json b/Tests/TechTalk.SpecFlow.Specs/specflow.json deleted file mode 100644 index 679fa267a..000000000 --- a/Tests/TechTalk.SpecFlow.Specs/specflow.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "cucumber-messages": { - "enabled": true - } -} diff --git a/changelog.txt b/changelog.txt index 05aa05b45..19b164719 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,8 @@ +3.10 + +Changes: ++ Remove Cucumber- Messages + 3.9 Features: diff --git a/docs/Tools/Cucumber-Messages.md b/docs/Tools/Cucumber-Messages.md deleted file mode 100644 index 890fa14b2..000000000 --- a/docs/Tools/Cucumber-Messages.md +++ /dev/null @@ -1,91 +0,0 @@ -# Cucumber Messages - -Cucumber messages provide a set of standardised messages across all Cucumber implementations. These messages are emitted when running your scenarios. - -A standardised set of messages make it possible to write tools (e.g. report generators) that work for all Cucumber implementations, such as SpecFlow, Cucumber JVM, Cucumber Ruby, Cucumber.js etc. - -Cucumber messages are sent to sinks, which you can configure. If Cucumber messages are enabled, but no sinks are configured, a file sink with the default path `cucumbermessages\messages` is used. - -## Configuration - -You can configure Cucumber messages in your specflow.json configuration file, or in the the SpecFlow section of your App.config (.NET Framework only). - -The App.config specifications can be found [here](https://github.com/techtalk/SpecFlow/blob/master/Tests/TechTalk.SpecFlow.Specs/Features/Configuration/Cucumber-Messages%20App.Config%20Configuration.feature). - -The specflow.json specifications can be found [here](https://github.com/techtalk/SpecFlow/blob/master/Tests/TechTalk.SpecFlow.Specs/Features/Configuration/Cucumber-Messages%20Json%20Configuration.feature) . - -### Enabled - -You can enable or disable the generation of Cucumber Messages by setting `enabled` to "true" or "false" in your configuration. The following defaults apply depending on the version of SpecFlow you are using: - -- SpecFlow 3.1: Cucumber messages are disabled by default. -- SpecFlow 3.2 and later: Cucumber messages are enabled by default. - -#### Example: Enabling Cucumber Messages - -**specflow.json** - -``` -{ - "cucumber-messages": { - "enabled": true - } -} -``` - -**App.config** - -``` - - - -
- - - - - - -``` - -Set `enabled` to "false" to disable the Cucumber messages. - -### Sinks - -Sinks determine where Cucumber messages are sent. If Cucumber messages are enabled, but no sinks are configured, a file sink with the default path `cucumbermessages\messages` is used. - -Use the `type` property to determine the type of sink. - -#### File Sinks - -When using file sinks (`type="file"`), Cucumber messages are written to the file specified using the `path` property. - -#### Example: File Sinks - -**specflow.json** - -``` -{ - "cucumber-messages": { - "enabled": true, - "sinks": [ - { - "type": "file", - "path": "custom_cucumber_messages_file.cm" - } - ] - } -} -``` - -**App.config** - -``` - - - - - - - -``` \ No newline at end of file diff --git a/docs/index.rst b/docs/index.rst index 4aa53739d..60a508623 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -168,8 +168,7 @@ You can find a number of step- by- step guides to start with SpecFlow `here -