General developer forum

phpunit testing

 
Picture of ashok kumar
phpunit testing
 

Hi ,


I am a newbie , i would like to create a a module and need to do a unit test, i went through assign module and checked the phpunit tests written with in the module under tests folder , i would like to check the tests written under that module "mod\assign\tests\base_test.php"

so i tried to execute the below command,

moodle313\mod\assign\tests>phpunit base_test.php

no output on phpunit were returned,

I have followed the steps to install phpunit given on the moodle documentation , also added the path to phpunit in environmental variable.

Please help me on how can i run unit test on assign module. correct me if i am wrong.

Thanks,

Ashok.



 
Average of ratings: -
Renaat
Re: phpunit testing
Core developersParticularly helpful MoodlersPlugin developers

php admin/tool/phpunit/cli/init.php
php admin/tool/phpunit/cli/util.php --buildcomponentconfigs
vendor/bin/phpunit -c mod/assign

 
Average of ratings: -
Picture of ashok kumar
Re: phpunit testing
 

Hi Rennat Debleu ,


Thank you for your reply,


I can execute the first two commands but on running "vendor/bin/phpunit -c mod/assign"

D:\path to moodle dir\moodle313>vendor/bin/phpunit -c mod/assign

'vendor' is not recognized as an internal or external command,

operable program or batch file.


Please forgive me if i missing some thing , and could you help me on this.


Thanks in advance,


Kind regards,

Ashok.



 
Average of ratings: -
Picture of ashok kumar
Re: phpunit testing
 

Hi Rennat Debleu ,


An update,


I tried to execute the below command after adding the path ".... vendor/bin/" in environmental variable, i receive the below errors,


D:\path to moodle dir\moodle313>phpunit -c mod/assign

PHP Warning:  include_once(PHPUnit/Extensions/Database/Autoload.php): failed to open stream: No such file or directory in D:\path to moodle dir\moodle313\lib\phpunit\bootstrap.php on line 83


Warning: include_once(PHPUnit/Extensions/Database/Autoload.php): failed to open stream: No such file or directory in D:\path to moodle dir\moodle313\lib\phpunit\bootstrap.php on line 83

PHP Warning:  include_once(): Failed opening 'PHPUnit/Extensions/Database/Autoload.php' for inclusion (include_path='D:\xampp_new\php\PEAR') in 

D:\path to moodle dir\moodle313\lib\phpunit\bootstrap.php on line 83


Warning: include_once(): Failed opening 'PHPUnit/Extensions/Database/Autoload.php' for inclusion (include_path='D:\xampp_new\php\PEAR') in 

D:\path to moodle dir\moodle313\lib\phpunit\bootstrap.php on line 83

Moodle can not find required PHPUnit extension phpunit/DbUnit


It seems like  "phpunit/DbUnit" extension not available , can you please  help me out to resolve this.


Thanks in advance.


 
Average of ratings: -
Picture of Michael Aherne
Re: phpunit testing
Core developersParticularly helpful MoodlersPlugin developers

If you're using Windows (which you seem to be), you'll need to use the correct directory separator: vendor\bin\phpunit instead of vendor/bin/phpunit

 
Average of ratings: -
Tim at Lone Pine Koala Sanctuary
Re: phpunit testing
Core developersDocumentation writersParticularly helpful MoodlersPlugin developers

Or, use a sensible shell, like the one you get when you install msysgit.

 
Average of ratings: -