DevShop is a testing platform as well as a hosting system.
To get started with automated testing with devshop:
- Enable the "devshop_testing" module.
This can be done in Admin > Hosting, or Admin > Modules, or using drush.
- Visit your project's settings page.
- In the "Testing" section, select the type of testing you would like to run.
Currently the only options are SimpleTest and Behat. This will grow over time.
- Enter the "Behat folder path" for your project. This is where your Behat composer.json file lives.
- Hit "Save".
- Create a directory for tests and create a composer.json file in it:
$ mkdir tests
$ cd tests
$ vim composer.json
Add the following to your composer.json file, as instructed in the Behat Drupal Extension Documentation:
{
"require": {
"drupal/drupal-extension": "~3.0"
},
"config": {
"bin-dir": "bin/"
}
}
- Run
composer install. - Create a
behat.ymlfile with the following contents:
default:
suites:
default:
contexts:
- FeatureContext
- Drupal\DrupalExtension\Context\DrupalContext
- Drupal\DrupalExtension\Context\MinkContext
- Drupal\DrupalExtension\Context\MessageContext
- Drupal\DrupalExtension\Context\DrushContext
extensions:
Behat\MinkExtension:
goutte: ~
selenium2: ~
base_url: http://default
Drupal\DrupalExtension:
blackbox: ~
NOTE: When using devshop for testing, the base_url and drush alias configuration in your behat.yml file doesn't matter. DevShop will automatically re-write the behat.yml to set the corrent base URL and drush alias. Feel free to set your base_url to match your localhost or any other domain.
-
Initialize Behat:
$ bin/behat --init -
Add the required files to git:
Since devshop will run composer install for you, you only need to include the following files in your behat tests folder to get tests running on devshop:
features
.gitignore # Should be set to ignore "vendor"
behat.yml
composer.json
composer.lock
- Write your behat tests and put them into the
featuresfolder. See the Behat Documentation for more info on how to write tests.
A simple test example:
Feature: I can see the homepage
In order to know what site I am on
As a visitor
I should see the site title on the homepage.
Scenario: See the site title on the homepage.
Given I am on the homepage
Then I should see "My Lovely Website"
- Deploy your new code to an environment.
- Check the project settings to ensure the path to tests is accurate. If so, you should see a set of checkboxes with all of your feature files listed. Leave unselected to run all of the tests.
- Run Tests:
You can manually Run Tests by clicking the Environment Settings dropdown (slider icon) and then "Run Tests".
"Run Tests" is also available as a "Deploy Hook", meaning it will trigger a test run after code is deployed (via git push).
This allows for a continuous testing environment.