How to deal with unit-tests in Zend Framework 2? -
How to deal with unit-tests in Zend Framework 2? -
i have zend-framework 2 project , have problems organize unit-tests. unit-test located in 1 "test"-folder each module. if run test command line phpunit in test folder of module, test run successfully.
example:
c:\project\module\accesscontrol\test>phpunit
phpunit 3.7.14 sebastian bergmann. configuration read c:\project\module\accesscontrol\test\phpunit.xml ........time: 0 seconds, memory: 8.25mb ok (8 tests, 10 assertions)
problem: here 1 module testet. want run single testsuite folder c:\project\ test hole project. there have set bootstrap.php , phpunit.xml.
from command line run with:
c:\project\tests>phpunit --debug --configuration phpunit.xml
phpunit 3.7.14 sebastian bergmann. configuration read c:\project\tests\phpunit.xml starting test 'accesscontroltest\model\authenticationtest::testinitdefault'. php fatal error: class 'accesscontroltest\bootstrap' not found in c:\project\module\accesscontrol\test\accesscontroltest\model\authenticationtest.php on line 22 php stack trace: php 1. {main}() c:\program files (x86)\php\phpunit:0 php 2. phpunit_textui_command::main() c:\program files (x86)\php\phpunit:46 php 3. phpunit_textui_command->run() c:\program files (x86)\php\pear\phpunit\textui\command.php:129 php 4. phpunit_textui_testrunner->dorun() c:\program files (x86)\php\pear\phpunit\textui\command.php:176 php 5. phpunit_framework_testsuite->run() c:\program files (x86)\php\pear\phpunit\textui\testrunner.php:346 php 6. phpunit_framework_testsuite->run() c:\program files (x86)\php\pear\phpunit\framework\testsuite.php:705 php 7. phpunit_framework_testsuite->runtest() c:\program files (x86)\php\pear\phpunit\framework\testsuite.php:745 php 8. phpunit_framework_testcase->run() c:\program files (x86)\php\pear\phpunit\framework\testsuite.php:775 php 9. phpunit_framework_testresult->run() c:\program files (x86)\php\pear\phpunit\framework\testcase.php:769 php 10. phpunit_framework_testcase->runbare() c:\program files (x86)\php\pear\phpunit\framework\testresult.php:648 php 11. accesscontroltest\model\authenticationtest->setup() c:\program files (x86)\php\pear\phpunit\framework\testcase.php:821
the file phpunit.xml looks this:
<phpunit bootstrap="./bootstrap.php" colors="true" verbose="true"> <testsuite name="sgtrcatalogtestsuite"> <directory>../module/accesscontrol</directory> </testsuite> </phpunit>
it looks modulepaths not correct. can help , tell me how setup this?
edit ty replys!!!
in meantime found this: how consolidate zf2 unit/application module tests single call?
it seems not possible run module-tests rootlevel. seek utilize , allow u know if works: https://github.com/prolic/humusphpunitmodule
try adding section in composer.json
"autoload": { "psr-0": { "accesscontroltest\\": "tests/", "accesscontrol\\": "src/module/accesscontrol/src/" } }
and run
$ php composer.phar dump-autoload
unit-testing zend-framework2 phpunit
Comments
Post a Comment