khanh
khanh

Reputation: 4606

Cucumber and Seed data

can we load seed data when start cucumber? Please support me a way.

Upvotes: 1

Views: 2332

Answers (2)

Dean Radcliffe
Dean Radcliffe

Reputation: 2206

I prefer this approach:

https://github.com/cucumber/cucumber/wiki/fixtures

I'm not opening the fixtures vs factories debate, of course, just saying that I've yet to see a case where files of data (seed, or otherwise) cease to be useful.

Once yaml fixtures are defined, they can be instantiated procedurally via Fixtures.create_fixtures per above, or set up as rake tasks.

They're just plain files, not code intended to have side effects - I have more confidence letting non-technical people add their data to fixtures files (esp. CSV).

Upvotes: 3

Jesse Wolgamott
Jesse Wolgamott

Reputation: 40277

You could use Factory Girl to in your cucumber tests to setup your 'stuff'

Background:
  A car exists

Scenario: I drive a car
  Given I am in a car
  And I have keys in the ignition
  When I turn the keys
  ...

Then you'll create the car in your step definitions, with something like

@car = Factory.create(:car)

Upvotes: 4

Related Questions