Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement event-based progress notification to replace IScenarioNotifier / IFeatureNotifier #225

Closed
2 of 3 tasks
Suremaker opened this issue Feb 25, 2021 · 1 comment
Closed
2 of 3 tasks
Labels
non-functional Non functional change, like refactoring, build scripts etc
Milestone

Comments

@Suremaker
Copy link
Collaborator

Suremaker commented Feb 25, 2021

Description

Implement event-based progress notification capability, that:

  • provides time-series events related to feature / scenario / step execution,
  • provides easy to consume listening mechanism,
  • provides the ability to extend the event types without impacting the existing consumers.

The issue with IScenarioNotifier / IFeatureNotifier

  • The existing interfaces do not allow adding new types of notifications without breaking existing implementations.
  • Even if the consumer is interested to consume specific notification, all methods of the interface needs to be implemented.
  • The existing notifications do not provide information about the time when they occurred in a consistent manner.

Progress

  • Feature is implemented,
  • Ensured backward-compatibility,
  • Ensured good debugging experience
@Suremaker Suremaker added the non-functional Non functional change, like refactoring, build scripts etc label Feb 25, 2021
@Suremaker Suremaker added this to the 3.4.0 milestone Feb 25, 2021
Suremaker added a commit that referenced this issue Feb 27, 2021
Suremaker added a commit that referenced this issue Feb 27, 2021
…nd related types

Updated all code to use IProgressNotifier implementations instead
Suremaker added a commit that referenced this issue Feb 28, 2021
Suremaker added a commit that referenced this issue Feb 28, 2021
@Suremaker
Copy link
Collaborator Author

Suremaker commented Feb 28, 2021

The IProgressNotifier interface has been introduced and replaced IScenarioProgressNotifier and IFeatureProgressNotifier.

Unlike previous interfaces IProgressNotifier has only one method:

public interface IProgressNotifier
{
    void Notify(ProgressEvent e);
}

It is used now to send notifications about all events happening during test execution, where LightBDD.Core.Notification.Events namespace has all available events defined.

Registration

While all existing notifiers (DefaultProgressNotifier, NoProgressNotifier, ParallelProgressNotifierProvider) have been updated to support the new interface, they need to be registered using new configuration section:

configuration.ProgressNotifierConfiguration()
    .Clear()
    .Append(new DefaultProgressNotifier(Console.WriteLine));

While it was possible to create IScenarioProgressNotifier for the specific scenario, all IProgressNotifier instances are created at once and used for all fixtures and scenarios.

In order to get access to fixture specific outputs, the ScenarioExecutionContext can be used:

configuration.ProgressNotifierConfiguration()
    .Clear()
    .Append(new DefaultProgressNotifier(message => ScenarioExecutionContext
        .GetCurrentScenarioFixtureIfPresent<ITestOutputProvider>()
        ?.TestOutput
        .WriteLine(message)));

Please note that GetCurrentScenarioFixtureIfPresent() will return null when the notification is made out of the scenario context, thus it has to be checked before using TestOutput.

This use case may get simplified before the release, but if anything, it will get implemented in separate ticket

Benefits of the new approach

The main benefit is that LightBDD can now get extended to provide more notifications without breaking the interfaces and requiring all implementations to handle all notifications.

@Suremaker Suremaker removed this from the 3.4.0 milestone Nov 7, 2021
@Suremaker Suremaker added this to the 3.5.0 milestone Jun 25, 2022
@Suremaker Suremaker mentioned this issue Jul 31, 2022
5 tasks
Suremaker added a commit that referenced this issue Aug 7, 2022
#260 (LightBDD.MsTest2)(Change) Updated MSTest.TestFramework to 2.2.10
#260 (LightBDD.NUnit3)(Change) Updated NUnit dependency to 3.13.3
#260 (LightBDD.Fixie2)(Change) Dropped netcoreapp2.0 support
#260 (Examples) Removed Example.LightBDD.MsTest2.UWP project as UWP is deprecated
#255 (LightBDD.Core) Added IStep.AttachFile() method allowing to add file attachments to steps and fired StepFileAttached progress notification event when attachment is made
#255 (LightBDD.Core) Added ReportWritersConfiguration.UpdateFileAttachmentsManager() to allow re-configuring file attachments storage
#255 (LightBDD.Framework) Added support to attach files to steps with StepExecution.Current.AttachFile()
#255 (LightBDD.Framework) Added FileAttachmentManager implementation and registered it with ReportWritersConfiguration.RegisterDefaultFileAttachmentManager() extension method to create attachments in ~/Reports folder
#255 (LightBDD.Framework) Updated DefaultProgressNotifier to notify on StepFileAttached event
#255 (LightBDD.Framework) Updated HtmlResultTextWriter / PlainTextReportFormatter / XmlReportFormatter to include file attachments
#225 (Core)(New) Introduced IProgressNotifier and processing events: FeatureStarting, FeatureFinished, ScenarioStarting, ScenarioFinished, StepStarting, StepFinished, StepCommented
#225 (Core)(New) Extended ScenarioExecutionContext with GetCurrentScenarioFixtureIfPresent to return fixture object executing given scenario
#225 (Framework)(New) Introduced ProgressNotifierConfiguration to configure IProgressNotifier instances and updated DefaultProgressNotifier, NoProgressNotifier to implement IProgressNotifier and added ParallelProgressNotifierProvider.CreateProgressNotifier() method
#225 (LightBDD.XUnit2/LightBDD.NUnit3/LightBDD.MsTest2/LightBDD.Fixie2)(Change) Updated projects to use IProgressNotifier configuration
#225 (Core/Framework)(Change) Obsoleted IScenarioProgressNotifier, IFeatureProgressNotifier, DelegatingScenarioProgressNotifier, DelegatingFeatureProgressNotifier and all methods using them
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
non-functional Non functional change, like refactoring, build scripts etc
Projects
None yet
Development

No branches or pull requests

1 participant