From 5b1d86ca9be163e8f3d1ea018d9fc48d73bb9065 Mon Sep 17 00:00:00 2001 From: Mark Hoek Date: Mon, 24 Jan 2022 21:46:51 +0100 Subject: [PATCH 1/3] Create test for ITestOutputHelper problem --- .../ITestOutputHelper.feature | 8 +++++ .../ITestOutputHelperSteps.cs | 34 +++++++++++++++++++ .../TestDependencies.cs | 1 + 3 files changed, 43 insertions(+) create mode 100644 SpecFlow.DependencyInjection.Tests/ITestOutputHelper.feature create mode 100644 SpecFlow.DependencyInjection.Tests/ITestOutputHelperSteps.cs diff --git a/SpecFlow.DependencyInjection.Tests/ITestOutputHelper.feature b/SpecFlow.DependencyInjection.Tests/ITestOutputHelper.feature new file mode 100644 index 0000000..edc98f7 --- /dev/null +++ b/SpecFlow.DependencyInjection.Tests/ITestOutputHelper.feature @@ -0,0 +1,8 @@ +Feature: ITestOutputHelper + Issue #75: ITestOutputHelper unavailable when using SpecFlow.xUnit + https://github.com/solidtoken/SpecFlow.DependencyInjection/issues/75 + +Scenario: Assert ITestOutputHelper Is Available + The When part here is purely for displaying the message using ITestOutputHelper + When a message is output using ITestOutputHelper + Then verify that ITestOutputHelper is correctly injected diff --git a/SpecFlow.DependencyInjection.Tests/ITestOutputHelperSteps.cs b/SpecFlow.DependencyInjection.Tests/ITestOutputHelperSteps.cs new file mode 100644 index 0000000..758c210 --- /dev/null +++ b/SpecFlow.DependencyInjection.Tests/ITestOutputHelperSteps.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using TechTalk.SpecFlow; +using Xunit; +using Xunit.Abstractions; + +namespace SolidToken.SpecFlow.DependencyInjection.Tests +{ + [Binding] + public class ITestOutputHelperSteps + { + private readonly ITestOutputHelper _output; + + public ITestOutputHelperSteps(ITestOutputHelper output) + { + _output = output; + } + + [When(@"a message is output using ITestOutputHelper")] + public void WhenAMessageIsOutputUsingITestOutputHelper() + { + _output.WriteLine("This is output from ITestOutputHelper"); + } + + [Then(@"verify that ITestOutputHelper is correctly injected")] + public void ThenVerifyThatITestOutputHelperIsCorrectlyInjected() + { + Assert.NotNull(_output); + } + } +} diff --git a/SpecFlow.DependencyInjection.Tests/TestDependencies.cs b/SpecFlow.DependencyInjection.Tests/TestDependencies.cs index 6eca4ce..d05e4c4 100644 --- a/SpecFlow.DependencyInjection.Tests/TestDependencies.cs +++ b/SpecFlow.DependencyInjection.Tests/TestDependencies.cs @@ -1,6 +1,7 @@ using System; using System.Linq; using Microsoft.Extensions.DependencyInjection; +using Xunit.Abstractions; namespace SolidToken.SpecFlow.DependencyInjection.Tests { From 4d61d5520f5b2e05eab19d44af405838eb6e1b1e Mon Sep 17 00:00:00 2001 From: Mark Hoek Date: Sun, 22 May 2022 12:37:20 +0200 Subject: [PATCH 2/3] Use ISpecFlowOutputHelper instead of ITestOutputHelper Fixes: #75 --- .../ISpecFlowOutputHelper.feature | 8 +++++ .../ISpecFlowOutputHelperSteps.cs | 35 +++++++++++++++++++ .../ITestOutputHelper.feature | 8 ----- .../ITestOutputHelperSteps.cs | 34 ------------------ 4 files changed, 43 insertions(+), 42 deletions(-) create mode 100644 SpecFlow.DependencyInjection.Tests/ISpecFlowOutputHelper.feature create mode 100644 SpecFlow.DependencyInjection.Tests/ISpecFlowOutputHelperSteps.cs delete mode 100644 SpecFlow.DependencyInjection.Tests/ITestOutputHelper.feature delete mode 100644 SpecFlow.DependencyInjection.Tests/ITestOutputHelperSteps.cs diff --git a/SpecFlow.DependencyInjection.Tests/ISpecFlowOutputHelper.feature b/SpecFlow.DependencyInjection.Tests/ISpecFlowOutputHelper.feature new file mode 100644 index 0000000..7d58dc9 --- /dev/null +++ b/SpecFlow.DependencyInjection.Tests/ISpecFlowOutputHelper.feature @@ -0,0 +1,8 @@ +Feature: ISpecFlowOutputHelper + Issue #75: ITestOutputHelper unavailable when using SpecFlow.xUnit + https://github.com/solidtoken/SpecFlow.DependencyInjection/issues/75 + +Scenario: Assert ISpecFlowOutputHelper Is Available + The When part here is purely for displaying the message using ISpecFlowOutputHelper + When a message is output using ISpecFlowOutputHelper + Then verify that ISpecFlowOutputHelper is correctly injected diff --git a/SpecFlow.DependencyInjection.Tests/ISpecFlowOutputHelperSteps.cs b/SpecFlow.DependencyInjection.Tests/ISpecFlowOutputHelperSteps.cs new file mode 100644 index 0000000..c0a88b0 --- /dev/null +++ b/SpecFlow.DependencyInjection.Tests/ISpecFlowOutputHelperSteps.cs @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using TechTalk.SpecFlow; +using TechTalk.SpecFlow.Infrastructure; +using Xunit; +using Xunit.Abstractions; + +namespace SolidToken.SpecFlow.DependencyInjection.Tests +{ + [Binding] + public class ISpecFlowOutputHelperSteps + { + private readonly ISpecFlowOutputHelper _output; + + public ISpecFlowOutputHelperSteps(ISpecFlowOutputHelper output) + { + _output = output; + } + + [When(@"a message is output using ISpecFlowOutputHelper")] + public void WhenAMessageIsOutputUsingISpecFlowOutputHelper() + { + _output.WriteLine("This is output from ISpecFlowOutputHelper"); + } + + [Then(@"verify that ISpecFlowOutputHelper is correctly injected")] + public void ThenVerifyThatISpecFlowOutputHelperIsCorrectlyInjected() + { + Assert.NotNull(_output); + } + } +} diff --git a/SpecFlow.DependencyInjection.Tests/ITestOutputHelper.feature b/SpecFlow.DependencyInjection.Tests/ITestOutputHelper.feature deleted file mode 100644 index edc98f7..0000000 --- a/SpecFlow.DependencyInjection.Tests/ITestOutputHelper.feature +++ /dev/null @@ -1,8 +0,0 @@ -Feature: ITestOutputHelper - Issue #75: ITestOutputHelper unavailable when using SpecFlow.xUnit - https://github.com/solidtoken/SpecFlow.DependencyInjection/issues/75 - -Scenario: Assert ITestOutputHelper Is Available - The When part here is purely for displaying the message using ITestOutputHelper - When a message is output using ITestOutputHelper - Then verify that ITestOutputHelper is correctly injected diff --git a/SpecFlow.DependencyInjection.Tests/ITestOutputHelperSteps.cs b/SpecFlow.DependencyInjection.Tests/ITestOutputHelperSteps.cs deleted file mode 100644 index 758c210..0000000 --- a/SpecFlow.DependencyInjection.Tests/ITestOutputHelperSteps.cs +++ /dev/null @@ -1,34 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using TechTalk.SpecFlow; -using Xunit; -using Xunit.Abstractions; - -namespace SolidToken.SpecFlow.DependencyInjection.Tests -{ - [Binding] - public class ITestOutputHelperSteps - { - private readonly ITestOutputHelper _output; - - public ITestOutputHelperSteps(ITestOutputHelper output) - { - _output = output; - } - - [When(@"a message is output using ITestOutputHelper")] - public void WhenAMessageIsOutputUsingITestOutputHelper() - { - _output.WriteLine("This is output from ITestOutputHelper"); - } - - [Then(@"verify that ITestOutputHelper is correctly injected")] - public void ThenVerifyThatITestOutputHelperIsCorrectlyInjected() - { - Assert.NotNull(_output); - } - } -} From b9f046cbde81afafad5d32556918d6e800d6a1a8 Mon Sep 17 00:00:00 2001 From: Mark Hoek Date: Sun, 22 May 2022 12:40:31 +0200 Subject: [PATCH 3/3] Remove unnecessary usings --- .../ISpecFlowOutputHelperSteps.cs | 1 - SpecFlow.DependencyInjection.Tests/TestDependencies.cs | 5 +---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/SpecFlow.DependencyInjection.Tests/ISpecFlowOutputHelperSteps.cs b/SpecFlow.DependencyInjection.Tests/ISpecFlowOutputHelperSteps.cs index c0a88b0..9ffff28 100644 --- a/SpecFlow.DependencyInjection.Tests/ISpecFlowOutputHelperSteps.cs +++ b/SpecFlow.DependencyInjection.Tests/ISpecFlowOutputHelperSteps.cs @@ -6,7 +6,6 @@ using TechTalk.SpecFlow; using TechTalk.SpecFlow.Infrastructure; using Xunit; -using Xunit.Abstractions; namespace SolidToken.SpecFlow.DependencyInjection.Tests { diff --git a/SpecFlow.DependencyInjection.Tests/TestDependencies.cs b/SpecFlow.DependencyInjection.Tests/TestDependencies.cs index d05e4c4..a3375dd 100644 --- a/SpecFlow.DependencyInjection.Tests/TestDependencies.cs +++ b/SpecFlow.DependencyInjection.Tests/TestDependencies.cs @@ -1,7 +1,4 @@ -using System; -using System.Linq; -using Microsoft.Extensions.DependencyInjection; -using Xunit.Abstractions; +using Microsoft.Extensions.DependencyInjection; namespace SolidToken.SpecFlow.DependencyInjection.Tests {