Tips to Speed up Your PHPunit Tests

I came across this collection of “Tips to Speed up Your PHPunit Tests“. Apart from the few usual ones, like disabling XDebug and using groups, I found a couple that linked to handy tools:

  • ParaTest – a PHPUnit extension that runs PHPUnit tests in parallel, significantly minimizing the test run time, and
  • PHPUnit Report – a tool that visualizes test run times, clearly showing which unit tests take the longest to run.

Very cool! Needs trying …

atoum – modern, simple and intuitive PHP unit testing framework


With all the hype around the quality assurance and testing tools for PHP, I wonder how did I miss atoum.  Atoum is a modern, simple and intuitive unit testing framework for PHP.  From a quick look around, it seems to be a lot simpler than PHPUnit and I definitely need to find some time to give it a go.

Also, here’s a blog post that describes how Automattic moved from PHPUnit to atoum, which makes a lot of sense (you know what I’m talking about if you ever tried to write PHPUnit tests for WordPress projects).




Improving the output of PHPUnit


Via “Improving the output of PHPUnit” I’ve learned about PHPUnit Emoji Result Printer.  Obviously, this sounds like fun, but I’m also sure there is some really smart way of using this.

Too bad I couldn’t try it on one of our work projects just yet, as this requires PHPUnit 6+, while we are still on PHPUnit 5.7.  But we’ll get there.




PHPUnit Snapshot Assertions – a way to test without writing actual test cases


phpunit-snapshot-assertions – is an interesting addition to the PHPUnit assertions which allows testing against previously created snapshots.  This is particularly useful for testing the outputs of API end-points, format conversion functions, and the like.  Instead of testing the actual functionality, these assertions allow to compare the output of the current test run with the known good output of a previously created snapshot.

This works well for generic text, but even better for widely used formats like JSON and XML, where, in case of a failed assertion, a meaningful difference can be provided.

Here is a blog post providing some more details on philosophy and methodology.




PHPQA all-in-one Analyzer CLI tool


PHPQA all-in-one Analyzer CLI tool.  This project bundles together all the usual PHP quality control tools, and then some.  It simplifies the installation and configuration of the tools and helps developers to push up the quality control bar on their projects.

The tools currently included are: