Automated Testing
Automated Testing with DevShop
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".
Setting up your project for testing
Create a directory for tests and create a composer.json file in it:
Add the following to your
composer.json
file, as instructed in the Behat Drupal Extension Documentation:Run
composer install
.Create a
behat.yml
file with the following contents: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:
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:Write your behat tests and put them into the
features
folder. See the Behat Documentation for more info on how to write tests.A simple test example:
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.
Last updated