Skip to content

Commit

Permalink
Adding a test case list to the test suite cli runner
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzo committed Jul 13, 2010
1 parent eed9d93 commit 01cfe32
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 1 deletion.
61 changes: 61 additions & 0 deletions cake/console/libs/testsuite.php
Expand Up @@ -42,8 +42,10 @@ public function initialize() {
} else {
define('TEST_CAKE_CORE_INCLUDE_PATH', CAKE_CORE_INCLUDE_PATH);
}

$this->_dispatcher = new CakeTestSuiteDispatcher();
$this->_dispatcher->loadTestFramework();
require_once CAKE . 'tests' . DS . 'lib' . DS . 'test_manager.php';
}

/**
Expand Down Expand Up @@ -113,6 +115,65 @@ public function main() {
$testCli->run($this->runnerOptions());
}

/**
* Shows a list of available test cases and gives the option to run one of them
*
* @return void
*/
public function available() {
$params = $this->parseArgs();
$testCases = TestManager::getTestCaseList($params);
$app = $params['app'];
$plugin = $params['plugin'];

$title = "Core Test Cases:";
$category = 'core';
if ($app) {
$title = "App Test Cases:";
$category = 'app';
} elseif ($plugin) {
$title = Inflector::humanize($plugin) . " Test Cases:";
$category = $plugin;
}

if (empty($testCases)) {
$this->out(__('No test cases available'));
return;
}

$this->out($title);
$i = 1;
$cases = array();
foreach ($testCases as $testCaseFile => $testCase) {
$case = explode(DS, str_replace('.test.php', '', $testCase));
$case[count($case) - 1] = Inflector::camelize($case[count($case) - 1]);
$case = implode('/', $case);
$this->out("[$i] $case");
$cases[$i] = $case;
$i++;
}

while ($choice = $this->in(__('What test case would you like to run?'), null, 'q')) {
if (is_numeric($choice) && isset($cases[$choice])) {
$this->args[0] = $category;
$this->args[1] = $cases[$choice];
$this->main();
break;
}

if (is_string($choice) && in_array($choice, $cases)) {
$this->args[0] = $category;
$this->args[1] = $choice;
$this->main();
break;
}

if ($choice == 'q') {
break;
}
}
}

/**
* Help screen
*
Expand Down
2 changes: 1 addition & 1 deletion cake/tests/lib/test_runner.php
Expand Up @@ -20,7 +20,7 @@


require 'PHPUnit/TextUI/Command.php';
require 'test_manager.php';
require_once 'test_manager.php';

PHPUnit_Util_Filter::addFileToFilter(__FILE__, 'DEFAULT');

Expand Down

0 comments on commit 01cfe32

Please sign in to comment.