0

I have following sample:

Scenario Outline: Example
Given I am a user
When I enter <x> as an amount
Then the result should be <result>
Examples:
    | example description   | x | result |
    | Example Description 1 | 3 | 3      |
    | Example Description 2 | 1 | 1      |

It provides names like:

enter image description here

I am not able to associate test case since I am getting very long names for test scenario.

Is there a way to get names like or similar:

Example_ExampleDescription1
Example_ExampleDescription2

I picked samples from: Updating the name of SpecFlow scenario outline variations

cashmere
  • 885
  • 3
  • 12
  • 37

1 Answers1

1

For what it's worth, if you're looking to differentiate by example name, and you have different descriptions for your examples, I'd suggest considering using separate scenarios instead of a scenario outline. It's OK to repeat scenarios, even if they seem familiar, as long as they tell you something distinct enough that you'd want to be able to read it separately.

Imagine, instead:

Scenario: Example Description 1
Given I am a user
When I enter 3 as an amount
Then the result should be 3

Scenario: Example Description 2
Given I am a user
When I enter 1 as an amount
Then the result should be 1

If those two scenarios are different enough, then there's no need to do a scenario outline just to read them differently; it's OK to repeat them. If they're just data points for the same example, they likely don't warrant their own description as part of the data point -- or, the scenario itself could be re-written to make such a description less necessary.

If you're looking to better surface these for non-coder consumption, you could also go the route of SpecFlow's LivingDoc (there's also a tool called Pickles that works similarly):

  • Run dotnet tool install --global SpecFlow.Plus.LivingDoc.CLI to install the CLI
  • cd to your specs folder
  • Run livingdoc feature-folder .

This will generate an HTML file that will show you the specs, the steps, and will allow folks to toggle the data for a given scenario outline on and off, or to select a given run from a scenario outline and see the data used.

SeanKilleen
  • 8,809
  • 17
  • 80
  • 133