-
Notifications
You must be signed in to change notification settings - Fork 41
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
Produce a cleaner scenario output #183
Comments
Hello @junalmeida, Let me start with the reasoning of current behavior: The progress notifiers reports two lines per step as they are reporting when given step starts and when ends. Such approach can be useful, as it shows what is actually going on, especially when:
Let's take a look at this code: using LightBDD.Framework;
using LightBDD.Framework.Scenarios;
using LightBDD.NUnit3;
using NUnit.Framework;
using System;
using System.Threading;
namespace LightBDDTests1
{
public class My_feature : FeatureFixture
{
[Scenario]
public void Some_scenario()
{
Runner.RunScenario(
Given_I_have_a_basket,
When_I_add_5_eggs_to_the_basket,
When_I_add_2_eggs_to_the_basket,
Then_I_should_have_7_items_in_the_basket);
}
private void Given_I_have_a_basket()
{
TestContext.Progress.WriteLine("Logging context creation....");
}
private void When_I_add_2_eggs_to_the_basket()
{
Console.Error.WriteLine("Some console writes...");
}
private void When_I_add_5_eggs_to_the_basket()
{
StepExecution.Current.Comment("adding more eggs");
}
private void Then_I_should_have_7_items_in_the_basket()
{
Thread.Sleep(5000);
TestContext.Progress.WriteLine("Simulated some super long task....");
}
}
} Running
Reporting step start and step end separately, gives here more context on what is going on and actually it is printed on console as the scenario progresses. Please let me know if that makes sense or if that does not give value for you... If you are not happy with the current implementation of the notifiers, you can provide yours. Here is a wiki page describing it: Test Progress Notification > Customizing progress notification. Unfortunately, there is no way to disable just printing the step start in the current notifiers, so you will have to provide full implementation of it:
Having said that, I will leave this ticket open to implement an easy way to override the behaviors of the notifiers without need of reimplementing them and will let you know of the progress. |
Thank you very much for this very clarifying answer, it helped me a lot to implement a custom notifier that produces a more readable version in my use case. Since all steps always execute in order, for me there is no point in repeating step description each comment or in the event of finish. Anyway, If this feature request makes no sense to the overall community that uses LightBDD, fell free to close it. Congratulations for the awesome lib. |
I am glad the response helped you and all is working now fine! If you could share your implementation of the notifier, I can always take a look at it and perhaps make it available in the library itself, so that the users will be able to pick the one that works better for them. I will leave this ticket open for a time being because you I believe there is a room for improvement in configuration of the notifiers.
Thanks a lot! It is great to hear it 😃 |
Hi, I've tried overriding the implementation as per the documentation, but it seems to be failing.
Then I copy and pasted to DefaultProgressNotifier, renaming it to DefaultProgressNotifier2. To make it compile I also had to copy and paste the TextTableRenderer and TextTreeRenderer as they are internal (might be useful to make them accessible by making them public or via some other means?). Ran the the test and it failed on the constructor: As you can see, it's being fed an empty action string array in the constructor (naturally, as I'm newing it up with nothing in the constructor). What am I doing wrong here? Where am I supposed to get the constructor arguments from? Thanks! EDIT I've fixed it by passing it this:
You mentioned it in the documentation, but I guess it wasn't immediately clear from the example. Will leave this here in case anyone else has the same issue. |
Description
Produce a cleaner scenario output, by not repeating the entire given/when/then/and line for just state that it was a success or fail.
Progress
The text was updated successfully, but these errors were encountered: