Note that there are some explanatory texts on larger screens.

plurals
  1. POWhat is the best strategy for BDD testing which relies on data
    text
    copied!<p>What are some strategies for writing BDD tests, which can test behaviour that relies on certain data being in the system?</p> <p>For example, say I was working with the following scenario:</p> <pre><code>Feature: Search for friend In order to find a friend As a user I want to search my list of friends And filter by 'first name' </code></pre> <p>How could this test ever succeed unless/until some "dummy" friends had been entered into the system?</p> <p>More to the point, what "dummy" criteria would the test utilize?</p> <hr> <p>Should I hard-code the name of a friend, assuming it to already exist in the database?</p> <p><strong>But</strong> what if I move my code to a new environment with a fresh database?</p> <hr> <p>Or, should I write code to manually insert dummy data into the system prior to executing each test?</p> <p><strong>But</strong> this would be modifying the internal state of the application from within a test framework, which seems like a bad approach, since we're supposed to be treating the program as a black-box, and only dealing with it through an interface.</p> <hr> <p>Or, would I create other scenarios/tests, in which the data is created using an interface of the program? </p> <p>For example, 'Feature: Add a new friend to my list'. Then I could run that test, to add a user called 'Lucy', then run the 'Search for friend' tests to search for 'Lucy', which would now exist in the database.</p> <p><strong>But</strong>, then I'd be introducing dependencies between my scenarios, which contradicts the common advice that tests should be independently runnable.</p> <hr> <p>Which one the best strategy? Or is there a better way?</p>
 

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