I was just wondering if anyone else had been hit by this problem and if they had a sensible solution to it?
I've had a few cases where the install has failed when initialising behat tests (in the latest example a block plugin had a couple of junk files inside it, so the directory was not removed when I switched branches, so there was an error due to the lack of version.php in the directory).
This can lead to a situation where the database partially exists, but there is no 'behattest' field created in the config table.
Therefore Moodle refuses to believe this is a behat site - it won't let me run any tests or drop the database and re-initialise it.
Even adding the missing field to the config table does not work, as the config values are all cached (and purging the caches purges the main site cache, not the behat site cache).
The best solution I've found, is to comment out the 'is_test_site()' check, drop + rebuild the behat site (after fixing the initial error) and then put the check back in place.
Does anyone have a better solution than this?