diff --git a/Behavioral.Automation.DemoBindings/Bootstrapper.cs b/Behavioral.Automation.DemoBindings/Bootstrapper.cs index 42991498..1092c888 100644 --- a/Behavioral.Automation.DemoBindings/Bootstrapper.cs +++ b/Behavioral.Automation.DemoBindings/Bootstrapper.cs @@ -33,7 +33,6 @@ public void Bootstrap() Assert.SetRunner(_runner); _objectContainer.RegisterTypeAs(); _servicesBuilder.Build(); - Assert.SetConsumer(_objectContainer.Resolve()); _browserRunner.OpenChrome(); } } diff --git a/src/Behavioral.Automation.UnitTests/AssertionBuilderTests.cs b/src/Behavioral.Automation.UnitTests/AssertionBuilderTests.cs index 8ee5f133..0ffd66a4 100644 --- a/src/Behavioral.Automation.UnitTests/AssertionBuilderTests.cs +++ b/src/Behavioral.Automation.UnitTests/AssertionBuilderTests.cs @@ -22,11 +22,7 @@ public void OneTimeSetup() Mock wrapperMock = new Mock(); wrapperMock.Setup(w => w.StepInfoText).Returns("TEST"); - Mock consumerMock = new Mock(); - consumerMock.Setup(c => c.Get()).Returns(new[] { "TEST STEP" }); - BAssert.SetRunner(wrapperMock.Object); - BAssert.SetConsumer(consumerMock.Object); } [TestCase(0, false)] diff --git a/src/Behavioral.Automation/Bindings/ExecutionObserverBinding.cs b/src/Behavioral.Automation/Bindings/ExecutionObserverBinding.cs deleted file mode 100644 index 3578d739..00000000 --- a/src/Behavioral.Automation/Bindings/ExecutionObserverBinding.cs +++ /dev/null @@ -1,36 +0,0 @@ -using Behavioral.Automation.Services; -using TechTalk.SpecFlow; - -namespace Behavioral.Automation.Bindings -{ - [Binding] - public class ExecutionObserverBinding - { - private readonly ITestRunner _runner; - private readonly IScenarioExecutionConsumer _consumer; - - public ExecutionObserverBinding(ITestRunner runner, IScenarioExecutionConsumer consumer) - { - _runner = runner; - _consumer = consumer; - } - - [BeforeStep] - public void Consume() - { - var stageState = _runner.ScenarioContext.CurrentScenarioBlock; - var stage = "UNKNOWN"; - switch (stageState) - { - case ScenarioBlock.Given: stage = "Given"; - break; - case ScenarioBlock.When: stage = "When"; - break; - case ScenarioBlock.Then: stage = "Then"; - break; - } - var text = _runner.ScenarioContext.StepContext.StepInfo.Text; - _consumer.Consume($"{stage} {text}"); - } - } -} diff --git a/src/Behavioral.Automation/FluentAssertions/Assert.cs b/src/Behavioral.Automation/FluentAssertions/Assert.cs index 6fd2e5d8..ae03ca81 100644 --- a/src/Behavioral.Automation/FluentAssertions/Assert.cs +++ b/src/Behavioral.Automation/FluentAssertions/Assert.cs @@ -6,6 +6,7 @@ using Behavioral.Automation.FluentAssertions.Abstractions; using Behavioral.Automation.Model; using Behavioral.Automation.Services; +using NUnit.Framework; using OpenQA.Selenium; using TechTalk.SpecFlow; @@ -15,7 +16,6 @@ public static class Assert { private const int DefaultAttempts = 30; private static ITestRunnerWrapper _runner; - private static IScenarioExecutionConsumer _consumer; public static void SetRunner(ITestRunner runner) { @@ -27,11 +27,6 @@ public static void SetRunner(ITestRunnerWrapper runner) _runner = runner; } - public static void SetConsumer(IScenarioExecutionConsumer consumer) - { - _consumer = consumer; - } - public static T ShouldGet(Func predicate) { return TryGetValue(predicate, TimeSpan.FromMilliseconds(500)); @@ -93,7 +88,8 @@ public static void True(bool condition, string message) { if (!condition) { - NUnit.Framework.Assert.Fail(BuildMessage(message)); + TestContext.WriteLine($"\nActual:\n{message}"); + NUnit.Framework.Assert.Fail(); } } @@ -107,17 +103,6 @@ public static string BehaviorAppendix(this AssertionBehavior behavior) return string.Empty; } - private static string BuildMessage(string message) - { - IEnumerable executedSteps = _consumer.Get(); - string aggregatedSteps = ""; - if (executedSteps.Any()) - { - aggregatedSteps = _consumer.Get().Aggregate((x, y) => $"{x}\n{y}"); - } - return $"{aggregatedSteps}\n\nExpected:\n{_runner.StepInfoText}\nActual:\n{message}"; - } - private static T TryGetValue(Func getValue, TimeSpan wait, int attempts = 10) { var counter = 0; diff --git a/src/Behavioral.Automation/Services/IScenarioExecutionConsumer.cs b/src/Behavioral.Automation/Services/IScenarioExecutionConsumer.cs deleted file mode 100644 index 0ed62df6..00000000 --- a/src/Behavioral.Automation/Services/IScenarioExecutionConsumer.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System.Collections.Generic; - -namespace Behavioral.Automation.Services -{ - public interface IScenarioExecutionConsumer - { - void Consume(string text); - - IEnumerable Get(); - } -} \ No newline at end of file diff --git a/src/Behavioral.Automation/Services/ScenarioExecutionConsumer.cs b/src/Behavioral.Automation/Services/ScenarioExecutionConsumer.cs deleted file mode 100644 index 18adbb7d..00000000 --- a/src/Behavioral.Automation/Services/ScenarioExecutionConsumer.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System.Collections.Generic; -using System.Linq; - -namespace Behavioral.Automation.Services -{ - public sealed class ScenarioExecutionConsumer : IScenarioExecutionConsumer - { - private readonly List _steps; - - public ScenarioExecutionConsumer() - { - _steps = new List(); - } - - public void Consume(string text) => _steps.Add(text); - - public IEnumerable Get() => _steps.Take(_steps.Count - 1); - } -} diff --git a/src/Behavioral.Automation/TestServicesBuilder.cs b/src/Behavioral.Automation/TestServicesBuilder.cs index 347382c5..7c1703a9 100644 --- a/src/Behavioral.Automation/TestServicesBuilder.cs +++ b/src/Behavioral.Automation/TestServicesBuilder.cs @@ -16,7 +16,6 @@ public TestServicesBuilder(IObjectContainer objectContainer) public void Build() { - _objectContainer.RegisterTypeAs(); _objectContainer.RegisterTypeAs(); _objectContainer.RegisterTypeAs(); _objectContainer.RegisterTypeAs();