Skip to content
This repository has been archived by the owner on Dec 29, 2018. It is now read-only.

Add at least rudimentary Behat tests #7

Closed
geerlingguy opened this issue Mar 29, 2017 · 3 comments
Closed

Add at least rudimentary Behat tests #7

geerlingguy opened this issue Mar 29, 2017 · 3 comments

Comments

@geerlingguy
Copy link
Owner

See Drupal VM docs: http://docs.drupalvm.com/en/latest/extras/selenium/

And see BLT for more practical examples, too.

@geerlingguy
Copy link
Owner Author

composer require --dev drupal/drupal-extension

And also add selenium to installed_extras in vagrant.config.yml.

@geerlingguy
Copy link
Owner Author

Setup after that:

  1. Inside VM, cd into /var/www/drupal/tests (new directory)
  2. Create customized behat.yml following the Drupal VM Behat docs.
  3. Run ../vendor/bin/behat --init (using project-specific behat).
    - This creates a features folder in the tests directory.
  4. Create a feature file following the Drupal VM Behat docs (see below).
Feature: Test DrupalContext
  In order to prove the Behat is working correctly in Drupal VM
  As a developer
  I need to run a simple interface test

  Scenario: Viewing content in a region
    Given I am on the homepage
    Then I should see "This is a demonstration production Drupal 8 website" in the "content"

Once that's done, run ../vendor/bin/behat, and get:

vagrant@local:/var/www/drupal/tests$ ../vendor/bin/behat       
Feature: Test DrupalContext
  In order to prove the Behat is working correctly in Drupal VM
  As a developer
  I need to run a simple interface test

  Scenario: Viewing content in a region                                                      # features/web/HomeContent.feature:6
    Given I am on the homepage                                                               # Drupal\DrupalExtension\Context\MinkContext::iAmOnHomepage()
    Then I should see "This is a demonstration production Drupal 8 website" in the "content" # Drupal\DrupalExtension\Context\MinkContext::assertRegionText()

1 scenario (1 passed)
2 steps (2 passed)
0m2.29s (17.20Mb)

Yay!

@geerlingguy
Copy link
Owner Author

Follow-up issue: #8

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant