PHPUnit Test small part of your code You write a lot of these. Pretty fast For Modules, Plugins and/or any seperate - Test results of PHP functions/classes Primarily for your services. Functional From perspective of user Tests more generally functionality Simulates a web request Write less of these Slower For Modules, Plugins, Sites and/or any controller or twig template. Your twig templates. Only for testing Controllers. 9 All testing is done with Codeception ❤
call-stack • If it can be functional, make it functional (i.e. validators). • Restructure for testing. • Don’t test non-essential methods When testing validate() should you also test the return result of the rules() of your model. Functional • Test functionality • Don’t test UI specific. Test the features. • Controller functionality. When building a website should you check that a button is given a class or that clicking on it performs an action you want to perform? You know your app. Where could it break?
guide on Github/Craft docs which covers all steps to get started. • Craft’s testing suite • https://docs.craftcms.co m/v3/testing/testing-cra ft/getting-started.html Automatic A test suite will be added in a directory of your choosing. Also coming to a pluginfactory.io near you
when a PR is opened or some code is committed). • Get notified • Mostly free to implement. • See the Craft testing docs or Craft’s own tests. Continuous Delivery/Deployment • Everything from CI • Cancel builds if tests fail. • Either automatic deploys or by pushing a button. • Reduces risk of site breaking builds. Still, don’t deploy on a friday
fresh Database before tests Extends the Yii2 codeception module Module and plugin support Mocking support including testing Craft in full isolation Console command testing Run (site) Migrations before tests Ability to configure Craft in exactly the way you want for tests Email testing without sending emails Fixtures Event testing