Open Jazzman82 opened 4 years ago
Just for clarification: When using xunit, the command line is expected to be "dotnet test --filter Category=Something" instead of "dotnet test --filter TestCategory=Something" for the other two frameworks.
This is not a bug, but the way how xUnit works.
What SpecFlow does: transforms your scenario outline to InlineData
:
From this:
Scenario Outline: Test filters
Given a parameter named <name>
When testrun is started with filter
Then the correct tests are executed
@Something
Examples:
|name |
|Something|
@Different
Examples:
|name |
|different|
to this (auto-generated code):
[Xunit.SkippableTheoryAttribute(DisplayName="Test filters")]
[Xunit.TraitAttribute("Description", "Test filters")]
[Xunit.InlineDataAttribute("Something", new string[] { "Something" })]
[Xunit.InlineDataAttribute("different", new string[] { "Different" })]
public virtual void TestFilters(string name, string[] exampleTags)
Or something like this, if you would write the code:
[Theory]
[InlineData("Something", new string[] { "Something" })]
[InlineData("different", new string[] { "Different" })]
public virtual void TestFilters(string name, string[] exampleTags)
Currently it is not possible to control which InlineData
to execute (execute all or none of them, but you cannot apply Trait
on the individual InlineData
attributes to filter them)
However they are working on this, and hopefully it will be available with xunit3. Check https://github.com/xunit/xunit/issues/1758 for further details.
When using a tagged Examples-Section in a Scenario Outline, the tags are not translated to xunit-category traits and therefore cannot be controlled by the --filter argument of the
dotnet test
-command.SpecFlow Version:
Used Test Runner
Version number:
Project Format of the SpecFlow project
packages.config
<PackageReference>
tags.feature.cs files are generated using
SpecFlow.Tools.MsBuild.Generation
NuGet packageSpecFlowSingleFileGenerator
custom toolVisual Studio Version
Enable SpecFlowSingleFileGenerator Custom Tool
option in Visual Studio extension settingsAre the latest Visual Studio updates installed?
<Major>.<Minor>.<Patch>
.NET Framework:
Test Execution Method:
<SpecFlow> Section in app.config or content of specflow.json
Repro Project
https://github.com/Jazzman82/SpecFlowTagsInScenarioOutline
Issue Description
Steps to Reproduce
In the linked repo, there are projects for MSTest, NUnit and xUnit with the same sources for the .feature and the StepDefinitions.cs. When you run the tests with
dotnet test --filter TestCategory=Something
then exactly one test should be executed. This works for MSTest and NUnit but not for xUnit - No test is found.I think this is because in the generated feature.cs-File, the tag is not present on the methods.