A detailed explanation of unit testing for WordPress, with examples for setting up tests in a variety of explanations. Plus it has Lego in the featured image! :)
Thorsten is a web developer since 2000, working with (and on) WordPress since 2005. Currently, Thorsten is a WordPress engineer and technical project lead at Inpsyde, Germany’s biggest WordPress agency. He is part of Inpsyde’s QA team, and leads the development of MultilingualPress, the multisite-based free open source plugin for your multilingual websites. He also maintains WP REST Starter, a Composer package for working with the WordPress REST API in an object-oriented fashion.
Thorsten is a certified PHP engineer, web development professional and tester.
If you are a software developer, you might have come across the term “testable code”. But what is it? What makes code testable, and what not?
Every piece of software is testable—somehow. There are several things you might be able to test:
the return value of a function;
the output of a function;
other side effects of executing a function;
whether or not a program crashes;
So, doesn’t that mean every piece of code is testable code?
It does not. That’s because almost always when someone refers to “testable code” they do it in the context of unit testing. So