Adding Test Suite to a New Project¶
Within your Drupal module path (e.g.
sites/all/modules/my_module), run the following.
composer require statonlab/tripal-test-suite --dev
Automatic Set Up¶
TestSuite can automatically configure your tests directory, PHPUnit bootstrap files, and travis continuous integration file as well as provide an example test and an example database seeder to get you started.
From your module’s directory, execute:
# You may specify the module name or leave it blank. # When left blank, the name of the current directory will be used as the module name. ./vendor/bin/tripaltest init [MODULE_NAME]
- Set up the testing framework by creating the tests directory,
- Create an example test in
- Create a DatabaseSeeders folder and an example seeder in
DevSeedSeeder.phpin DatabaseSeers. See the Database Seeders section to learn more about automatically populating the database with biological data.
- Create an example
.travis.ymlconfigured to use a tripal3 docker container to run your tests
You can now write tests in your
tests folder. To enable continuous
integration testing, push your module to github and enable Travis CI.
init command is run (see: Automatic Set Up), an
example.env file is created in
This file should be copied to
tests/.env and modified to describe your specific Drupal environment.
# tests/.env BASE_URL=http://localhost DRUPAL_ROOT=/var/www/html FAKER_LOCALE=en_US
- BASE_URL: The URL of your site. This is where you point your browser to view your site.
- DRUPAL_ROOT: The absolute path to your Drupal site. On Unix machines, this is often
/var/www/html, but it may be different on your setup.
- FAKER_LOCALE: Test Suite uses the Faker package to create fake data in factories. You can change the locale setting for the fake words used.
Drupal_ROOT variable is not set correctly, Drupal may not be bootstrapped correctly, and your tests may fail.
To force replacing files that tripaltest have perviously generated, you can use the
--force flag. You will need to confirm this flag by typing
y and hitting
./vendor/bin/tripaltest init --force
Joining an Existing Project¶
If Test Suite is already configured for a project (for example, if you clone Tripal and want to run tests), the
composer.json file already specifies what version of Test Suite is in use. To install it, execute the below command.
Before you can run tests, you’ll first need to configure your Environment Variables in the