142 - 6 Ways to improve your code tests
How To Code Well - A podcast by Peter Fisher - Fridays
Categories:
Change log: All the code notes for Docker for beginners course has been written. This is available on GitHub I’ve started work on transcribing that course. This will take a long time. I’ve fixed issues on howtocodewell.net regarding signup, forgotten password and other minor fixes I’ve added the functionality to lock and unlock courses. This will turn them into private or public courses that require enrolment 6 ways to improve your testing 1) Automate as much as you can Use CI pipelines Run these locally even if your’e not committing any changes Include other code auditing tools such as phpstan or phpmd 2) Statics are evil There is no way to test a static method that calls another static method 3) Having many mocks is an indication of bad code design 4) Use tests to help refactor you code If a unit of work cannot be easily tested then it usually means the code is not designed well Break up your tests into smaller chunks Tests can highlight micro and minor refactors Refactor your code and then re test Try and do this in a TDD fashion 5) Avoid flaky tests Clean up state Check for bottle necks which could cause timeouts Mock external services or dependancies Look into potential memory leaks 6) Re think what testing means to you Testing is a contractual agreement between the programmer and the code Testing is documentation - Gherkin, Acceptance Criteria, Business requirements Testing is boundary setting which helps with focus Testing is future proofing Watch the show on YouTube Contact me and let me know your thoughts or get something read out on air. My web development courses ➡️ Learn How to build a JavaScript Tip Calculator ➡️ Learn JavaScript arrays ➡️ Learn PHP arrays ➡️ Learn Python ✉️ Get my weekly newsletter ⏰ My current live coding schedule (Times are BST) Thursdays 20:00 = Live Podcast YouTube Sundays 14:30 - Live coding on Twitch