SpecFlow
SpecFlow copied to clipboard
@ignore tag for Examples generates incorrect NUnit code (Ignored true instead of IgnoreReason)
SpecFlow Version
3.9.74
Which test runner are you using?
NUnit
Test Runner Version Number
3.13.3
.NET Implementation
.NET Core 3.1
Project Format of the SpecFlow project
Sdk-style project format
.feature.cs files are generated using
SpecFlow.Tools.MsBuild.Generation
Test Execution Method
Resharper Test Runner
SpecFlow Section in app.config or content of specflow.json
No response
Issue Description
When adding the @ignore tag to Examples, the generated code for NUnit looks like this:
[NUnit.Framework.TestAttribute()] [NUnit.Framework.DescriptionAttribute("Option to Display Fruit")] [NUnit.Framework.TestCaseAttribute("banana", null)] [NUnit.Framework.TestCaseAttribute("apple", null)] [NUnit.Framework.TestCaseAttribute("mango", null, Ignored=true)] public void OptionToDisplayFruit(string fruit, string[] exampleTags)
TestCaseAttribute with Ignored=true does not compile for NUnit3 as it should use IgnoreReason="reason for ignoring"
This looks like it was fixed in the past in Issue 517 but appears to have regressed.
Steps to Reproduce
Example .feature file:
Scenario Outline: Option to Display Fruit Given I have something When I do some action Then I have the option to pick a <fruit>
Examples: | fruit | | banana | | apple |
@ignore Examples: | fruit | | mango |
Link to Repro Project
No response
We run our integration tests against NUnit 3.13.1 and they are all green. So it irritates me that we generate incorrect NUnit code. Is it an build error or only a warning?
Hi @SabotageAndi - I get the following build error: ##[error]PathToFeatureFile(44,59): Error CS0246: The type or namespace name 'Ignored' could not be found (are you missing a using directive or an assembly reference?)
@tedhols could you create a project where we can reproduce this issue?
Sure - sample project attached. SampleProject.zip
@SabotageAndi I forgot to mention in the description I get the same result whether I build within Visual Studio 2022 or using MSBuild on the command line.
Thanks for the project. Now I see where the problem is. We generate invalid code when you put the ignore tag on an example group if there are multiple. Looks like we have a case not covered by our integration tests.
@SabotageAndi Hello! Could you inform if any news about fixing this problem? Or could you say how to fix it temporary?
I just ran into the exact same issue.
if I use code just like this:
IUnitTestRuntimeProvider.TestIgnore({"message here"});
With Nunit the issue that this shows on the living doc as a fail has been a bug for a long time.