What is the best data-driven BDD testing strategy

What are some strategies for writing BDD tests that can test behavior based on specific data in the system?

For example, let's say I worked with the following script:

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'

How could this test ever succeed if / until the dummy friends logged in?

To what extent will the dummy criteria be used for testing?


Should I hard-write the name of a friend, assuming it already exists in the database?

But , what if I transfer my code to a new environment with a fresh database?


Or, do I have to write code to manually insert dummy data into the system before each test runs?

, , , .


/, ?

, "Feature: ". , "", " " "", .

, , , .


? ?

+5
2

Given, . .

, :

Background:
  Given I have the following friends:
    | andy smith   |
    | andy jones   |
    | andrew brown |

, :

def add_friend(name)
  Friend.create!(:name => name)
end

, :

def add_friend(name)
  visit '/friends/new'
  fill_in 'Name', :with => name
  click_button 'Add'
end

, :

Scenario: Searching for a existing person by first name
  When I search for 'andy'
  Then I should see the friends:
    | andy smith |
    | andy jones |
  But I should not see "andrew brown"

Scenario: Searching for a non-existing person by first name
  When I search for 'peter'
  Then I should not see any friends

, , , . , - . , " ", Cucumber Rails.

+4

BDD . ORM (NHibernate?), , , db , .

pre/post, , , , .

+2

All Articles