Re: AllTests.php and pear run-tests

From: Date: Tue, 03 Jul 2007 08:42:24 +0000
Subject: Re: AllTests.php and pear run-tests
References: 1 2 3  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-47160@lists.php.net to get a copy of this message
Christian Weiske schrieb: >> After sleeping a night over it, I found another method that would >> work but is not really good: <?php >> if (class_exists('AllTests')) { >> $classname = 'HTML_BBCodeParser_AllTests'; >> } else { >> $classname = 'AllTests'; >> } >> class $classname { >> ... >> } >> ?> > > That will not work since most AllTests.php automatically run Alltests::main() at the end of the > script. http://www.phpunit.de/pocket_guide/3.1/en/organizing-test-suites.html [Package]/tests/AllTest.php: <?php if (! defined('PEAR_ALL_TESTS')) { define('PEAR_ALL_TESTS', 'PEAR_[Package]_AllTests::main'); } /** * */ require_once 'PHPUnit/Framework.php'; require_once 'PHPUnit/TextUI/TestRunner.php'; require_once {tests} ... class PEAR_[Package]_AllTests { public static function main() { $parameters = array(); PHPUnit_TextUI_TestRunner::run(self::suite(), $parameters); } public static function suite() { $suite = new PHPUnit_Framework_TestSuite('PEAR [Package]'); $suite->addTestSuite('tests'); ... return $suite; } } if (PEAR_ALL_TESTS === 'PEAR_[Package]_AllTests::main') { echo '<pre>'; PEAR_[Package]_AllTests::main(); echo '</pre>'; } ?> /AllTests.php: <?php if (! defined('PEAR_ALL_TESTS')) { define('PEAR_ALL_TESTS', 'PEAR_AllTests::main'); } /** * */ require_once 'PHPUnit/Framework.php'; require_once 'PHPUnit/TextUI/TestRunner.php'; require_once [Package]/tests/AllTest.php ... class PEAR_AllTests { public static function main() { $parameters = array(); PHPUnit_TextUI_TestRunner::run(self::suite(), $parameters); } public static function suite() { $suite = new PHPUnit_Framework_TestSuite('PEAR'); $suite->addTestSuite([Package]_AllTests::suite()); ... return $suite; } } if (PEAR_ALL_TESTS === 'PEAR_AllTests::main') { echo '<pre>'; PEAR_AllTests::main(); echo '</pre>'; } ?> -- Sebastian Mendel www.sebastianmendel.de

« previous php.pear.dev (#47160) next »