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.22k stars 752 forks source link

Livingdoc: Custom step definition not included in HTML's list of unused step definitions #2610

Open adrichem opened 2 years ago

adrichem commented 2 years ago

SpecFlow Version

SpecFlow 3.9.74 and livingdoc 3.9.57

Which test runner are you using?

MSTest

Test Runner Version Number

2.2.10

.NET Implementation

equal or greater .NET Framework 4.6.1

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

No response

Issue Description

The analytics tab in the HTML document shows a badge with a number of unused step-definitions. However, the list does not show any unused step-defs. When I choose JSON output instead of HTML, then I do see the details of each unused step-def in the array.

This occurs for methods decorated with a custom attribute derived from StepDefinitionBaseAttribute. The normal Given, When, Then and StepDefinition attributes work fine.

Steps to Reproduce

Define a custom step-definition attribute like this:

    public class SpecFlowActionAttribute : StepDefinitionBaseAttribute
    {
        public SpecFlowActionAttribute() : this(null) { }
        public SpecFlowActionAttribute(string regex) : base(regex, new[] { StepDefinitionType.Given, StepDefinitionType.When }) { }
        public SpecFlowActionAttribute(string regex, string culture) : this(regex) { Culture = culture; }
    }

Create a new step-definition with this new attribute, but do not use it in any feature file. Run the tests.

Create the living doc using a command-like this livingdoc.exe feature-folder . --binding-assemblies <all relevant assemblies here>

Link to Repro Project

No response