I would like to start incorporating testing into the code that I develop. I have looked at what ships with Yii’s advanced application template and set up basic testing for a contact form that I wrote for one of my projects. I have some extensions I developed that I pull into my projects and I would like to put some testing into them and have some questions.
The testing that I had written for my application was using Yii’s integration with codeception. I started down the path thinking I’d do that for my extensions, but looking at all of Yii’s official extensions, they seem to be written using PHPUnit instead. For example, the basic app template (https://github.com/yiisoft/yii2-app-basic) has the codeception.yml file but the queue extension (https://github.com/yiisoft/yii2-queue) has the phpunit.xml.dist file.
From what I’ve gathered looking into this, PHPUnit may be best suited for extensions because in extensions we’re more concerned about the base functionality of the code therein than any type of user interaction. So, unit tests make the most sense, and PHPUnit seems to be preferred for that. Can anyone shed any insights into this for me?
On the other hand, for a full-fledged application which is intended to provide a specific user experience and may be made up of many extensions with contextual applications, we would want to have more functional and acceptance tests. Codeception provides Unit, Functional, and Acceptance testing, so this is why I assume the app-templates (basic and advanced) use Codeception and codeception.yml files. Does this sound right?
So, my assumptions are that it is a better practice using PHPUnit for testing in extensions I develop and Codeception for testing in the apps. I’m sure that some of this is up to developer preference, but I have very little experience in this area and am looking for the insights of those who do.
Please let me know your thoughts; thanks!