Xunit.Gherkin.Quick icon indicating copy to clipboard operation
Xunit.Gherkin.Quick copied to clipboard

DataTable and DocString in Scenario Outline - don't inject examples by default

Open ttutisani opened this issue 1 year ago • 0 comments

This is a tech debt.

By default, example values are injected into DocString and DataTable. This makes it impossible to have these arguments with values that look like placeholders but are not. e.g., a DocString containing <a> will always receive an example value from a column named "a".

This issue - https://github.com/ttutisani/Xunit.Gherkin.Quick/issues/145 - explains one of the possible implementations for supporting both kinds of arguments, in one of my comments. Specifically (everything below is a quote from the issue):

=================================

So, the right way would be to have difference between a DocString that does not ingest example values (that will be a default behavior), and a DocString that ingests parameter values. I see two options for that.

Option 1: I think this can be simpler - to add an annotation to DocString indicating it's not a default behavior.

[When(@"code block is sent")]
public void CodeBlockIsSent([IngectExampleValues] DocString codeBlock)
{
    System.Console.WriteLine(codeBlock.Content);
}

Option 2: this will be more work and only do this if the first option is impossible - introduce a new argument type to indicate it's not a default behavior.

[When(@"code block is sent")]
public void CodeBlockIsSent(DocStringFromExample codeBlock)
{
    System.Console.WriteLine(codeBlock.Content);
}

Apply the same fix for DataTable.

ttutisani avatar Mar 11 '24 22:03 ttutisani