Académique Documents
Professionnel Documents
Culture Documents
Major Drupal 6 modules are starting to get unit tests, but their
correctness varies.
Each .test file may contain one or more classes that extend
DrupalWebTestCase.
The main assertions that are built into the UnitTestCase class
(from which DrupalWebTestCase inherits) are documented at
http://simpletest.org/api/SimpleTest/UnitTester/
UnitTestCase.html .
$this->assertEqual(preg_match($regex, 'i<3badlyformattedtags'), 0,
t('XML Element Regex is valid'));
$this->assertEqual(preg_match($regex, 'georss:point'), 1, t('XML Element Regex is valid'));
$this->assertEqual(preg_match($regex, ' not:valid'), 0, t('XML Element Regex is valid'));
$this->assertEqual(preg_match($regex, '-not-so-valid'), 0, t('XML Element Regex is valid'));
}
$simplexml_result = simplexml_load_string($output);
http://hudson-ci.org/debian/
You can also run Hudson on Tomcat (beside a SOLR install, for
example.)
Set up a build step that runs SimpleTests via the shell script
Profit?
A sample script:
#!/bin/bash
SITE_PATH=/var/lib/hudson/jobs/ProvisionTest/workspace/trunk/
htdocs
cd $SITE_PATH
/bin/drush --root=$SITE_PATH --master_db_host=localhost --
master_db_user=root --db_type=mysql --db_host=localhost --
config_path=/etc/apache2/drush-conf --restart_cmd=echo --
uri=http://drushtest --script_user=hudson --profile=provision
provision install drushtest
Your install profile must install SimpleTest so that you can use
the run-tests.sh script to run a number of tests.
Once you’re running this patch, your Hudson runs will keep
track of the number of test passes and fails.
rm -rf scripts/tests/*.xml
/usr/bin/php scripts/run-tests.sh --url http://drushtest --xml
scripts/tests Provision
http://gist.github.com/249754
This code will let you make a unit test that installs your full install
profile (in this case, called “provision”) and can then run tests
against the fully-installed environment.
Make sure that you install Provision for both the Hudson /
Tomcat user and the main web user.