SpecFlow icon indicating copy to clipboard operation
SpecFlow copied to clipboard

Name generation for scenario outlines in NUnit 3.X

Open DannyBraig opened this issue 9 years ago • 6 comments

Hi everyone, I think i found some issue with the name generation for NUnit 3.x in combination with "scenario outlines".

According to the documentation:

For better traceability, the generated unit test method names are derived from the scenario outline title and the first value of the examples (first column of the examples table). It is therefore good practice to choose a unique and descriptive parameter as the first column in the example set. As the Gherkin syntax does require all example columns to have matching placeholders in the scenario outline, you can even introduce an arbitrary column in the example sets used to name tests with more readability.

Like this, I have definded the following dummy-scenario:

Scenario Outline: Some Scenario
When I am doing <x>
Then  the action <y> happens

Examples: 
| description | x | y |
| testcase1   | 1 | 1 |
| testcase2   | 2 | 2 |

I'd expect the UnitTest Name now to be shown as SomeScenario_testcase1

But actually it shows like SomeScenario("testcase1","1","1",System.String[] ).

the example i posted above generates to the following Nunit3 code:
 [NUnit.Framework.TestAttribute()]
        [NUnit.Framework.DescriptionAttribute("Some Scenario")]
        [NUnit.Framework.TestCaseAttribute("testcase1", "1", "1", new string[0])]
        [NUnit.Framework.TestCaseAttribute("testcase2", "2", "2", new string[0])]

I am not sure, but I think the behavior of NUnit seems to be correct here, because in the documentation it says the following about NUnit's "TestCase" Attribute:

TestName provides a name for the test. If not specified, a name is generated based on the method name and the arguments provided.

So the code should more look like

...
[NUnit.Framework.TestCaseAttribute("testcase1", "1", "1", new string[0], TestName= "SomeScenario_testcase1")
...

Please correct me if I am wrong.. Thanks!

DannyBraig avatar Nov 07 '16 12:11 DannyBraig

#1874

goblinmaks avatar Mar 30 '20 11:03 goblinmaks

Merged so this one could be closed :)

304NotModified avatar Apr 26 '20 22:04 304NotModified

But we reverted #1874 because of an issue in the NUnit3TestAdapter. So this is still open.

SabotageAndi avatar Apr 27 '20 08:04 SabotageAndi

@304NotModified we also heve discussion in https://github.com/SpecFlowOSS/SpecFlow/pull/1874

goblinmaks avatar Apr 27 '20 08:04 goblinmaks

Do you have any updates here? Can https://github.com/SpecFlowOSS/SpecFlow/pull/1874 be pushed?

Npalchuk avatar Nov 16 '23 15:11 Npalchuk

As I understand SF is not in active development now.

goblinmaks avatar Nov 17 '23 00:11 goblinmaks