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.25k stars 754 forks source link

Skip.If() is not possible in BeforeScenarioHook #2059

Open SabotageAndi opened 4 years ago

SabotageAndi commented 4 years ago

SpecFlow Version:

Used Test Runner

Version number:

Project Format of the SpecFlow project

.feature.cs files are generated using

Visual Studio Version

Enable SpecFlowSingleFileGenerator Custom Tool option in Visual Studio extension settings

Are the latest Visual Studio updates installed?

.NET Framework:

Test Execution Method:

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

Repro Project

  1. standard xUnit SpecFlow project
  2. add this hook
    [BeforeScenario()]
    public void BeforeScenario()
    {
    Skip.If(true);
    }
  3. run tests
  4. image

Issue Description

The Scenario should be skipped.
This works for bindings, but not for hooks.

bklebe commented 4 years ago

I would just like to add that I don't know about Skip.If() in xUnit but I used IUnitTestRuntimeProvider.TestIgnore as per https://docs.specflow.org/projects/specflow/en/latest/Execution/SkippingScenarios.html with NUnit in a BeforeScenario hook scoped to a specific tag and it seemed to work fine. Perhaps the documentation should be updated to say this limitation is xUnit-specific?

SabotageAndi commented 4 years ago

@bklebe Thanks for the info. The documentation page for it is here: https://github.com/SpecFlowOSS/SpecFlow/blob/master/docs/Execution/SkippingScenarios.md Would you adjust the documentation with this information?

bklebe commented 4 years ago

Happy to.