Configuration PHPUnit with phpt -
i'm totally stucked. @ first code:
file sample000.phpt
--test-- basic test --description-- lowlevel basic test --file-- <?php echo 'hello world!'; ?> --expect-- hello world!
file phpttestcase.php
<?php require_once 'phpunit/extensions/phpttestcase.php'; class phpttestcase extends phpunit_extensions_phpttestcase { public $result; public function __construct( $file ) { $options = array( 'include_path' => 'd:\\xampp\\php' ); parent::__construct( $file, $options ); } }
file phpttest.php
<?php class phpttest extends phpunit_framework_testcase { public $object; public function setup() {} public function teardown() {} public function testall() { require_once 'phpttestcase.php'; $file = __dir__ . '/phpt-tests/sample000.phpt'; $phpt = new phpttestcase( $file ); $result = $phpt->run(); $this->asserttrue( $result->wassuccessful() ); var_dump( $result->failures() ); } }
running pear run-tests sample000.phpt
command line work fine. running phpunit phpttest.php
fail.
after research dumped result var_dump( $result->failures() );
, see php executable couldn't found:
array(1) { [0] => class phpunit_framework_testfailure#441 (2) { protected $failedtest => class phpttestcase#434 (3) { public $result => null protected $filename => string(84) "d:\\htdocs\\[...]\\phpt/phpt-tests/sample000.phpt" protected $options => array(1) { ... } } protected $thrownexception => class phpunit_framework_comparisonfailure#440 (12) { protected $expected => string(12) "hello world!" protected $actual => string(94) "der befehl "c:\\php\\php.exe" ist entweder falsch geschrieben oder\nkonnte nicht gefunden werden." <-- snip --> protected $file => string(53) "d:\\xampp\\php\\pear\\phpunit\\extensions\\phpttestcase.php" protected $line => int(209) private $trace => array(17) { ... } private $previous => null } } }
i assume line why test fails when runs phpunit:
der befehl "c:\php\php.exe" ist entweder falsch geschrieben oder\nkonnte nicht gefunden werden.
translated: the "c: \ php \ php.exe" command either misspelled or not found. php executable installes in d:/xampp/php
i try setup include path in xml configuration file phpunit (phpunit.xml
) , try pass include path option class phpunit_extensions_phpttestcase
.
can tell me how configure phpunit can find php executable?
phpt support bundled in phpunit. can try this:
phpunit.xml:
<phpunit> <testsuites> <testsuite name="phpt tests"> <directory suffix=".phpt">phpt-tests</directory> </testsuite> </testsuites> </phpunit>
create directory phpt-tests , move sample000.phpt it.
run phpunit. load configuration phpunit.xml , run testsuite testing phpt tests phpt-tests directory.
$ phpunit phpunit 3.7.8 sebastian bergmann. configuration read phpunit.xml . time: 0 seconds, memory: 3.25mb ok (1 test, 1 assertion)
Comments
Post a Comment