Testable Drupal
A simple set of tools and files to make your Drupal Installation a Testable Drupal Installation.
Based on Behat, Mink and using Selenium2, Phantomjs and CasperJs, Testable Drupal provide a basic structure to integrate with your tests., (*1)
What it does
At this time Testable Drupal has basic tests to
* verify Drupal installation. - using Mink and CasperJs
* to perform a screenshot when required or when a test fail (if you are not using Goutte). - Using Mink
* to perform a 'node create' and 'node update' with interface interaction (waiting for the appearance of the menu, then click... etc). - Using CasperJs, (*2)
Integration are welcome :)
Components and requirements
Component installation
-
Install and configure your Drupal installation, (*3)
-
Download Composer in the root of your project, (*4)
curl -s https://getcomposer.org/installer | php
- If not present create in the root of your project a file with name composer.json with this content:
{
"require": {
"vincenzodibiaggio/testable-drupal": "*"
},
"minimum-stability": "dev",
"config": {
"bin-dir": "bin/"
}
}
- Download dependencies in your project directory
php composer.phar install
-
Download Selenium server, (*5)
-
Download PhantomJs, (*6)
-
Download CasperJs - Pay attention: to use all of feature the minimum version is 1.1-beta1 !, (*7)
-
Puth both PhantomJs and CasperJs executables in your PATH, (*8)
Configuration
Now Testable Drupal support two test suite
1. 'PHP': Behat/Mink/Selenium/PhantomJs using deep Drupal integration
2. 'JS': PhantomJs/CasperJs to deep interface behavior testing, (*9)
Testable Drupal 'PHP'
Configuration
- Modify paths and host in
tests/behat_dist.yml
: wd_host
, root
, drupal_root
- If you want you can rename
behat_dist.yml
in behat.yml
but if you launch behat --init
you overwrite it!
(if you launch a behat --init
for error you can use the FeatureContext_dist.php
to replace the new file), (*10)
Run suite
- Run Selenium2
java -jar selenium-server-standalone-YOUR_VERSION.jar -role hub
- Run PhantomJs
phantomjs --webdriver=8080 --webdriver-selenium-grid-hub=http://127.0.0.1:4444
- Run tests
cd vendor/vincenzodibiaggio/testable-drupal/tests
./../../../../bin/behat --config behat_dist.yml features/test.feature
Testable Drupal 'JS'
Configuration
- Modify values in
testable-drupal/jsTests/includes/includeCasper.js
- I'm working in a better integration with Drupal
I recommend to you: put both PhantomJs and CasperJs executables in your PATH. They work fine together without configuration ;), (*11)
Run suite
- Just run the test:
(if you respect the order of filenames you will create nodes and make other test on it... otherwise you will test a failure :D )
cd vendor/vincenzodibiaggio/testable-drupal/jsTests
casperjs test FILENAME