Wednesday 19 July 2017

A Practical Guide to Unit Testing Your Code


I’ve lost count of the number of posts I’ve read about unit testing; how to set it up, why you should do it, and what tools to use. It’s something I’ve been pushing myself to do and get better at but I’ve always struggled to translate what I’ve read about testing into writing tests for my own code. However, recently I feel like the principles I’ve been reading about are finally clicking in my brain and I’ve actually been able to successfully write unit tests for my code, including legacy codebases that I had previously thought were untestable. Recently, I’ve been working on changes to the internal plugin that extends the WooCommerce API on the Delicious Brains site. Previously the plugin had no unit tests and was a large, messy class with all the functionality stored inside it. The plugin allows our premium products to communicate with WooCommerce on the site for licensing and subscriptions and therefore extremely critical to our business. Before making large changes I decided to get some tests written, as well as perform some necessary refactoring. This post will serve as a practical guide to writing unit tests – what to test
Source: https://managewp.org/articles/15689/a-practical-guide-to-unit-testing-your-code




source https://williechiu40.wordpress.com/2017/07/20/a-practical-guide-to-unit-testing-your-code/

No comments:

Post a Comment