When use_site_clone is set to true behat_testing doesn't skip database cloning. Also, db cleaning method used when database is not cloned (for cleaning database tables from a chrased test) will wipe out the real database because drops real tables instead cloned ones.

Comments

tunic’s picture

Status: Needs review » Active
StatusFileSize
new2.5 KB

This patch fixs both commented issues.

behat_testing_setup recieves now a $clone_db param and will skip database cloning and db conection adjust if it's true.

Method prepareForTheSuite from DrupalContext gets use_site_clone form parameters and uses it when is called.

Also, behat_testing_clean_database now uses $table var, with the whole table name, instead of $matches [1], so the cloned tables are dropped instead of the original ones.

This patch applies to 1.0-alpha4 because there are some changes in dev and I could't ran it, but I guess it's very easy to port. I may do it if maintainers confirms current dev is in operational state (I'm not sure of it).

Thanks for this module!

EDIT: I've enhanced a the behat_testing_clean_database explanation for better comprension.

Pete B’s picture

Status: Active » Needs review

Thanks a lot for the patch tunic, we will test this ASAP.

Pete B’s picture

Status: Active » Closed (fixed)

Applied to the latest dev. Thanks!

johnennew’s picture

Hi all,

The rebuild profile is broken by the patch in #1:
drush be --profile=rebuild

The following patch improves on the above to offer 3 profiles:

default: Normal behaviour. Current site db is cloned and tests run on that. After each feature file is completed, the test db is wiped and cloned again. In this was changes caused by one feature file do not exist when the next feature file is run.

rebuild: In the rebuild profile, a test db is used but it's contents are populated by running a site install before every feature file set of tests is executed.

live: In the live profile, the tests are run on the live database. This is useful in a continuos development environment where the site being tested is a throw away clone of the real website.

johnennew’s picture

Version: 7.x-1.0-alpha4 » 7.x-1.x-dev
Status: Closed (fixed) » Fixed
StatusFileSize
new6.27 KB

OK, here's another patch.

This follows on from before, but I've changed the names of some of the parameters to make their use more obvious.

use_site_clone has been removed in favour of use_test_database. When set to true, the test db is created and the test db prefix is changed.

use_existing_clone is now use_existing_test_database. This is set to false in all profiles. It's purpose is for devs to set to true to stop the cloning process and just use the cloned db that already exists, this is ignored in the rebuild profile.

I've also changed the prefix number from 65 to 101, apologies if this causes problems but I thought it was important. If you need to clean up any left over 65 tables, enable the simpletest module and run the drush command:
drush test-clean

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.