Remotely Running Behat Drupal BDD Tests

So, you have a remote server that houses a Drupal instance that you want to test with Behat. I'm going to assume you have Behat set up with Drupal Extension and configured to run said tests on your local instance. Of course you have drush installed on the remote machine. If you have configured SSH on your computer to automatically log you in with a certificate rather than using usernames and passwords to that server, you're pretty much ready to go.

You'll need to update your drush aliases file (if you're using *NIX/Mac, that located in ~/.drush/aliases.drushrc.php). I keep a separate aliases file for each project I'm working on, so Project A's drush alias file would be named 'projectA.aliases.drushrc.php'.  The alias entry for that project would look like:

['projectA'] = array(
'uri' => '',
'root' => '/var/www',
'remote-host' => '',
'remote-user' => 'my_user_name',

In your behat.yml file, you'll need a new entry at the same level as 'default' that overrides certain items from the default profile.

        alias: projectA

The next time you want to run your Behat tests against your remote server, add the -p switch to the Behat command and add the name of your profile after that. In my case, that would be:

bin/behat -p projectA