Setting up automated tests for WordPress plugins

So no idea why this is always a pain for me. But I feel setting up automated tests for WordPress plugins and themes can be a headache – especially with the recent changes in PHPUnit 10+.
The official WordPress test suite isn’t compatible with PHPUnit 10+, and breaking changes in the framework mean many plugins and themes struggle to find stability. Throw into that something like Pest and it’s a arrgghhh. Pest ‘describe’ needs PHPUnit 10+ lol and everything just spirals.

After running into these issues myself and also there’s not much collective info about the issues you can encounter , I’ve created a ready-to-go testing and linting platform for WordPress development. At least i won’t have issues moving forwards. Ill update when higher versions are more stanble.
It uses PHPUnit 9.6 (for full WP compatibility), Pest for modern PHP testing, and PHPCS for code linting. The WordPress test environment is set up automatically – no more config nightmares but this is quite standard.

yeah yeah i know it’s standard stuff. It’s always been setup in companies so never an issue.

Just
– clone the repo into your plugin
– remove the .git references ( obviously you won’t need the repo )
– update the PSR-4 autoload namespace in composer.json as needed
– start testing.

I’ve thrown in some dummy tests, a couple of mocks with tests and a class in /src to lint

Save time, avoid version headaches, and focus on wizardry building those plugins and themes! Dont forget to test though lol

GitHub https://github.com/ssmason/WP-Plugin-Theme-Testing-Platform