Today we check out testing - hot topic! Do you cringe when you hear the dreaded T-word? Testing can be rewarding, this week, Jeremy Harris has passed on some top tips to make CakePHP testing better - A Data Provider can go a long way towards cleaning up duplicate logic in your tests
- Have CakePHP 3.5? It comes baked with a new way to test your console applications
- Fixtures slowing your tests down? Try `friendsofcake/fixturize`!
- Getting Started: Testing can be complicated, so start by writing a test for the simpler elements - like an Entity.
- Create a base test case class that all your classes extend. This makes future broad changes easy.
- Bake can help you generate fixtures quickly. Try `bin/cake bake fixture --help` for more info.
- Have an integration test confusing you with a rendered error? Turn off the error handling middleware to debug it
- Having trouble figuring out how to test a certain layer in CakePHP? The core test suite has tests for everything, and they serve as a great example.
So are you ready to get out there and test? If you have any other tips that you'd like to share, be sure to tweet about them! Don't forget to tag us #CakePHP Until next time! Megan Community manager |