To be able to test properly, you need to be able to mock dependencies. And to be able to do that, quite some code has to be changed to implement dependency injection.
Is there a plan to implement this and make proper unit testing possible?
Do you have more information on what we can expect in the 3.0 GA for this testing framework? We're adding unit, API, and end-to-end testing to several Craft plugins and client projects. What can we expect in this initial release?
@YP28 not necessarily. In Yii2 you can override components, and thus mock them.
@boboldehampsink I sure hope that's not where this is headed 馃槄
Edit: anyway, turns out 3.0 was released with hardly any unit tests. Is it still the plan to add this in the near future, @brandonkelly?
@YP28 Its worrying enough that Craft itself doesn't have tests 馃槄
Will be interesting to see the impact of Yii2.1 also which changes routing, adds dependency injection, adds middleware, etc. Details here https://github.com/yiisoft/yii2/milestones/2.1.0
Here is a Craft 3 plugin that uses the Codeception testing framework and is able to mock services: https://github.com/nerds-and-company/schematic
Still no news on that? Would love to be able to develop modules or plugins test driven :)
I'm very interested in using Craft as an application development framework, but the lack of an officially-supported story for testing plugins and modules makes it a tough sell.
As of Craft 3.2 BETA-1, there is now a formalized testing Framework for Craft. Based on Codeception with support for sites, modules and plugins in various testing styles.
Formal announcement here
Big +1 for @boboldehampsink for his help on this.
Most helpful comment
As of Craft 3.2 BETA-1, there is now a formalized testing Framework for Craft. Based on Codeception with support for sites, modules and plugins in various testing styles.
Formal announcement here
Big +1 for @boboldehampsink for his help on this.