simpleTest with Behat for Drupal 8
The first time I heard about Behat was at DrupalCon Munich 2012. Since then use of Behat has grown exponentially and the tools it can be integrate with grew as well. With Behat we can test the markup of a page - pretty neat, right?
Well, it's time to take Behat integration with Drupal a little further. I've decided to try and integrate it with Drupal's simpleTest, as this would open the door for writing simpleTests that are more readable and more "behavior driven" by nature.
<span class="k">Scenario:</span><span class="nf"> Testing the login form.</span><span class="k"> Given </span><span class="nf">I visit 'user'</span><span class="nf"> </span><span class="k">And </span><span class="nf">I fill in 'Username' with '@user-name'</span><span class="nf"> </span><span class="k">And </span><span class="nf">I fill in 'Password' with '@user-pass'</span><span class="nf"> </span><span class="k">When </span><span class="nf">I press 'Log in'</span><span class="nf"> </span><span class="k">Then </span><span class="nf">I should see '@user-name'</span>
Amazingly enough, the above Gherkin code which is being executed by PHPunit can test your Drupal installation!
Behat code executed from within Drupal's simpleTest
This functionality is provided by an experimental repo, which comes with an example test.