How Testing Benefits You
Lab: Unit & Integration Testing Basics
Video Runtime: 27:00
Notes | Transcript | Code | Playlist
Notes
Before we can really dive into testing, I think any conversation about integration testing into workflow has to start with “how it benefits you.” Testing requires more work from you upfront, but saves you time and money later. The benefits are huge to your company, clients, and you.
Let’s talk about why and what you get.
In this episode, I’ll show you the benefits of testing by showing you a real world framework that had a bug in it. As I was writing tests for it, I found a bug, one that had been in this framework for over 6 years. This function was supposed to:
- Remove the action
remove_action
from WordPress - And then add it back in with the new hook, i.e. do a
add_action
.
It’s expected behavior was to “replace” the hook for the given action.
It did the add action, but did not remove the original. That’s a bug. I’ll show you how testing found it and then how I fixed it.
We’ll talk in depth about the benefits to you and why it’s imperative that you learn testing and integrate it into your workflow. Here are the benefits:
- Gives you confidence in your work and code.
- Saves you time.
- Helps you to isolate behaviors and potential issues.
- Gives you a baseline for measuring future enhancements and/or changes.
- Required if you want to:
- Contribute to an open source project
- Start your career at a larger agency or company
Transcript
Code
-
Click here for the code and test
Hey... hey you... yes you!... Having a good time? Learning new things? Good!
Episodes
Total Lab Runtime: 04:26:49
- 1 Lab Introductionfree 13:13
- 2 How Testing Benefits Youfree 27:00
- 3 What is Testing?free 10:24
- 4 Unit vs. Integration Testsfree 17:44
- 5 Setup the Testing Environmentpro 12:21
- 6 PHPUnit & a Virtual Containerpro 08:37
- 7 Create the Composer.json Filepro 14:36
- 8 Configure PHPUnit for Both Test Suitespro 10:56
- 9 Setup Test Shortcuts in Composerpro 09:58
- 10 Setup Local's Web Serverfree 10:05
- 11 Unit Tests - Bootstrappro 14:34
- 12 Test Basicspro 12:24
- 13 Test Assertionspro 18:42
- 14 Unit Tests - Write Real Testspro 23:32
- 15 Integration Bootstrap - Overviewfree 09:01
- 16 Integration Bootstrap - Find the WordPress Test Suite's Directorypro 12:10
- 17 Integration Bootstrap - Defining Constantspro 04:06
- 18 Integration Bootstrap - Register Theme & Loadpro 07:41
- 19 Meet WP_UnitTestCasepro 12:05
- 20 Integration Tests - Write Real Testspro 15:18
- 21 Wrap it Upfree 02:22