Note that there are some explanatory texts on larger screens.

plurals
  1. POBDD: SpecFlow - Scenario Outline Behaviour Not As Expected
    primarykey
    data
    text
    <p>Using scenario outlines in SpecFlow, e.g.</p> <pre><code>Scenario Outline: Invalid Login Details Given some pre-conditions... When user "Larry" enters username &lt;username&gt; and password &lt;password&gt; Then the message "Invalid Login Details" should be displayed Examples: |username|password| |larry06 | | |larry06 |^&amp;*%*^$ | |%^&amp;&amp;** |pass123 | | |pass123 | </code></pre> <p>I expected that the "When" step would be evaluated as such:</p> <pre><code>public void WhenUserEntersUsernameAndPassword(String username, String password){} </code></pre> <p>And that the scenario would be run 4 times - for each row of the table, passing the values as required. <strong>That's not the case.</strong></p> <p>Instead, SpecFlow creates 1 of 4 required step definitions:</p> <pre><code>[When(@"""(.*)"" provides the following new username larry(.*) and password ")] public void WhenUserEntersUsernameLarryAndPassword(string p0, int p1) { //TODO } </code></pre> <p>And to get the remaining 3 to 'work' I need to manually write methods explicitly matching other values in the table.</p> <p>I've <em>since</em> realised that I can just say:</p> <pre><code>When "Larry" enters username "&lt;username&gt;" and password "&lt;password&gt;" </code></pre> <p>And I get:</p> <pre><code>[When(@"""(.*)"" provides the following ""(.*)"" and ""(.*)""")] public void WhenUserEntersUsernameAndPassword(string p0, string name, string pass) { //TODO } </code></pre> <p>Perfect.</p> <p>But all documentation seems to suggest I don't need "" and that should just work (e.g. <a href="https://github.com/cucumber/cucumber/wiki/Scenario-outlines" rel="nofollow">https://github.com/cucumber/cucumber/wiki/Scenario-outlines</a>). I note:</p> <blockquote> <p>"Your step definitions will never have to match a placeholder. They will need to match the values that will replace the placeholder"</p> </blockquote> <p>I just don't really see the value of writing separate step definitions for each line of the table.</p> <p>Is this nuance specific to SpecFlow?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload