WordPress limitations

Unfortunately, WordPress does not yet have a good way for you to reference common files between plugins. In the case of these tests, it would be more efficient to put them into some sort of global WordPress library so that multiple plugins could use the tests contained in a single testing class file. However, until our testing scripts get integrated into the WordPress core, you have to work with a couple of options.

The first option is that you can copy all your testing functions into a dedicated class used by only your plugin (as we did in the previous examples). The upside here is that this is guaranteed to work, but the downside is that it's inefficient—imagine if 100 plugins each copied the exact same tests. It would take ...

Get WordPress 3 Plugin Development Essentials now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.