开发者

Cucumber and Seed data

开发者_JAVA技巧

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


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)


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).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜