sizuhiko / Bdd

BDD(Behavior Driven Development) integration plugin for CakePHP2
28 stars 9 forks source link

Load all fixtures for stories? #12

Open sime opened 11 years ago

sime commented 11 years ago

Would it be possible to load all fixtures prior to running story tests?

For example could $hooks->beforeSuite() run CakeFixtureManager::fixturize() ?

Or is there another technique to populating the $test database. I'm finding it difficult to scale testing to multiple developers who constantly need to update the $test database schema.

sizuhiko commented 11 years ago

Are you using the migration plug-in?

https://github.com/CakeDC/migrations

I recommend its use.

cake Migrations.migration run all --connection test

sime commented 11 years ago

Yes. Using it as an interim.

The interesting thing about fixtures is that it supports $records. And it's quite easy to bake fixtures with $records:

$ cake bake fixture --records --count 10 Model
sizuhiko commented 11 years ago

OK, But, Why do you use fixture data? Dummy data made by bake will be not assertable. I think good that test data defines with table format in background section.

If you want use dummy data, my idea is followings: // feature Given Post has 10 article // step

$steps->Given('/^Post has (\d+) article$/', function($world, $times) {
  $world->truncateModel('Post');
  $post = $world->getModel('Post');
  for ($i = 0; $i < $times; $i++) {
    $post->create(....);
    $post->save();
  }
});
sime commented 11 years ago

I think I understand what you mean.

Are you referring to using to backgrounds in gherkin?

http://docs.behat.org/guides/1.gherkin.html#backgrounds