SpecFlow icon indicating copy to clipboard operation
SpecFlow copied to clipboard

@ignore tag for Examples generates incorrect NUnit code (Ignored true instead of IgnoreReason)

Open tedeff opened this issue 2 years ago • 9 comments

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

tedeff avatar Aug 22 '22 13:08 tedeff

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?

SabotageAndi avatar Aug 23 '22 06:08 SabotageAndi

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?)

tedeff avatar Aug 23 '22 08:08 tedeff

@tedhols could you create a project where we can reproduce this issue?

SabotageAndi avatar Aug 23 '22 08:08 SabotageAndi

Sure - sample project attached. SampleProject.zip

tedeff avatar Aug 23 '22 09:08 tedeff

@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.

tedeff avatar Aug 23 '22 09:08 tedeff

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 avatar Aug 24 '22 07:08 SabotageAndi

@SabotageAndi Hello! Could you inform if any news about fixing this problem? Or could you say how to fix it temporary?

Fortudie avatar Nov 16 '22 22:11 Fortudie

I just ran into the exact same issue.

osre77 avatar Jun 15 '23 11:06 osre77

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.

Moshex avatar Jun 15 '23 17:06 Moshex