SpecFlow icon indicating copy to clipboard operation
SpecFlow copied to clipboard

LivingDoc with Hooks

Open Naweap opened this issue 3 years ago • 5 comments

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

Naweap avatar Mar 18 '22 15:03 Naweap

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.

SabotageAndi avatar Mar 21 '22 14:03 SabotageAndi

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.

Naweap avatar Mar 21 '22 19:03 Naweap

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.

nvborisenko avatar Nov 15 '22 17:11 nvborisenko

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

alexjoybc avatar Apr 05 '24 16:04 alexjoybc

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

Naweap avatar Apr 05 '24 18:04 Naweap