SpecFlowOSS / SpecFlow

#1 .NET BDD Framework. SpecFlow automates your testing & works with your existing code. Find Bugs before they happen. Behavior Driven Development helps developers, testers, and business representatives to get a better understanding of their collaboration
https://www.specflow.org/
Other
2.23k stars 752 forks source link

LivingDoc with Hooks #2574

Open Naweap opened 2 years ago

Naweap commented 2 years ago

SpecFlow Version

3.9.7

Which test runner are you using?

NUnit

Test Runner Version Number

3.13.2

.NET Implementation

.NET 5.0

Project Format of the SpecFlow project

Sdk-style project format

.feature.cs files are generated using

SpecFlow.Tools.MsBuild.Generation NuGet package

Test Execution Method

Visual Studio Test Explorer

SpecFlow Section in app.config or content of specflow.json

{
  "bindingCulture": {
    "language": "en-us"
  },
  "language": {
    "feature": "en-us"
  },
  "stepAssemblies": [
    { "assembly": "SpecFlowSharedSteps" }
  ],
  "livingDocGenerator": {
    "enabled": true,
    "filePath": "TestExecution.json"
  }
}

Issue Description

I create an issue a few month ago regarding SpecFlow+ LivingDoc report generation.

I just want to be sure I fully understood the outcome.

@SabotageAndi if I'm following your answer from the issue #2532, whenever I'm using hooks, I can only print informations or attach files inside LivingDoc from the BeforeStep and AfterStep hooks ?

At the moment none of those operations are working from other hooks (AfterTestRun or AfterScenario for example) ?

Am I right ?

If I'm, do you think this kind of feature will be implemented by the future ? It would be very useful in my case.

Thanks for the clarification.

Steps to Reproduce

Example of my explanation in the issue description :

[AfterTestRun]
public static void AfterTestRun(ISpecFlowOutputHelper specFlowOutputHelper)
{
    specFlowOutputHelper.WriteLine("blablabla");
    //Console.WriteLine("blablabla");
}

Link to Repro Project

No response

SabotageAndi commented 2 years ago

Scenario Hooks are also working. But Testrun and Feature level are not implemented. The reasons why they are not implemented are:

  1. a technical one, there are some challenges that we connect the output with the correct feature
  2. a UX one. We never found a good way to display the output in livingdoc. Displaying a message from a TestRun hook at every scenario doesn't make sense for us.

Perhaps we will have a look at this again, but pretty sure not in the next 6 months.

Naweap commented 2 years ago

Thanks for your quick answer ! Alright, keep me updated !

I will find another way to archive my goal for now.

By the way, I planned to use SpecFlow and LivingDoc in general for most of my test projects. I'm really counting on this framework and would like to thanks you for the work you've already done.

nvborisenko commented 1 year ago

Also report doesn't contain failed scenarios if they failed in [BeforeFeature] hook.

[BeforeFeature]
public void BeforeFeature()
{
  throw new Exception();
}

Then scenarios are not marked as failed in the report.

alexjoybc commented 4 months ago

any update on fixing this? I understand the ux challenge, but it would be nice be able to access the hooks test output in the livedoc report

Naweap commented 4 months ago

@alexjoybc No update on this from my side. I personally switched to another report generator plugin. Still using SpecFlow with NUnit though.