Intro to Code Testing and Continuous Integration

Test early, test often, test always. You’ve probably heard similar adages many times before, but you’re still not writing tests for your code. Why is that?

Most likely, the reason you’re not testing your code is one of three common scenarios:

1. You don’t know how to test.
2. You don’t realize how much faster you can operate thanks to tests.
3. You don’t believe scripted testing is actually valuable to you.

In this presentation, I would like to tackle all of those issues and get you up and running with – and excited about – testing today.

It has never been easier to build tests for your WordPress projects than it is right now. Tools like WP-CLI can generate your complete testing infrastructure with just a couple of commands. Testing frameworks like Codeception allow you to quickly test complex, browser-based features than ever before. Integration tools like Travis CI (and many, many others) afford you the ability to push new code into a project and trust it doesn’t break already-tested functionality. In this presentation we’ll see how to use all of these to our advantage to rapidly prepare our software for testing.

With the hard parts out of the way, and in record time, we can spend the balance of our time together on the why, what, and how of testing. In fact, I’ll give you the why for free right now: automated testing will save you dozens of hours and potentially hundreds or thousands of dollars on every single project – and make you a more effective developer in the process!

Here’s the deal: you’re already testing your code to verify it works before passing it along for client review. The problem is that you’re running your tests manually. Manual tests are messy and leave plenty of room for error and every time you need to test again, guess what? You’re testing the same things manually… again.

When you script your tests what you’re actually doing is codifying the intended behavior of your software – you’re documenting how the system should behave for all to see. Moreover, you’re defining your test once and confirming the desired behavior forever. From now until the end of time you can be sure that your software behaves as desired just by running the tests again. As for the what and how of testing, well, you’ll need to watch the presentation for those. I promise, though, writing tests will allow you to to complete projects faster and with less effort than going without. I know it sounds counterintuitive, but that’s the magic of testing!

Sample Slides: https://docs.google.com/presentation/d/1tcbwrywrlJ1GzhG4HfQszKeBrZ6-CpcJAlE0zRVIqfA/edit?usp=sharing

Other Info: The slide deck is from a version of this talk I delivered privately to a group of 7-10 intermediate and advanced developers.

I’m interested in giving yet another presentation on code testing because I’ve often been frustrated by the quality of the testing presentations I’ve seen at WordCamps. In fact, frustrated to the point of postponing testing for nearly 2 years after the first couple of presentations that I attended.

Speaker