Skip to content

Commit

Permalink
Issue #468: Modified SimpleTest to allow running a single test method…
Browse files Browse the repository at this point in the history
… within a test class

* Example: TEST_METHOD=testIsPluginActive php tests/TestOfPluginMySQLDAO.php
  • Loading branch information
mwilkie authored and ginatrapani committed Dec 13, 2010
1 parent fe2f9f0 commit fbbe44c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
7 changes: 7 additions & 0 deletions tests/README.md
Expand Up @@ -70,3 +70,10 @@ To use it, add a line like this to your integration test:
To see your debug statements, run your test like so:

`TEST_DEBUG=1 php tests/test.php`


## Run a single test from a given TestCase

To run only a single test in a file, set the TEST_METHOD environment variable. For example:

$ TEST_METHOD=testIsPluginActive php tests/TestOfPluginMySQLDAO.php
5 changes: 5 additions & 0 deletions webapp/_lib/extlib/simpletest/test_case.php
Expand Up @@ -129,6 +129,11 @@ function run(&$reporter) {
$this->_reporter = &$reporter;
$started = false;
foreach ($this->getTests() as $method) {
if(isset($_ENV['TEST_METHOD']) && $method != $_ENV['TEST_METHOD']) {
continue;
} else if (isset($_ENV['TEST_METHOD'])) {
echo "Running Single Test: $method\n";
}
if ($reporter->shouldInvoke($this->getLabel(), $method)) {
$this->skip();
if ($this->_should_skip) {
Expand Down

0 comments on commit fbbe44c

Please sign in to comment.