Dieses Blog durchsuchen

Donnerstag, 4. August 2016

phpunit: sample configfile phpunit.xml to autoload dependencies

If you are using phpunit,  its good not to require phpunit or your own libraries in your testcases everytime.

You can use the composer autoloading to do that.

All you need is phpunit in the "vendor" folder of your application and composer installed.

If you do not have composer installed, follow this tutorial
http://magento2-tuts.blogspot.de/2016/08/ubuntu-install-composer.html


If you do not have phpunit installed you can follow this totorial
http://magento2-tuts.blogspot.de/2016/08/use-composer-to-install-phpunit.html


now you can simply add a file "phpunit.xml" in your projectroot with following content:
This will tell phpunit, to use the autoloading from "vendor/autoload" where all external libraries are included.


Now you can switch to your terminal and go tho the projectroot and type:

phpunit


Thats it. All your dependencies will be required automaticly and your testsuites in the folder app/test will be executed




Keine Kommentare:

Kommentar veröffentlichen