One of my personal missions over the last six months has been to shave seconds off of the WordPress and BuddyPress automated test suites. (WP’s tests run in under half the time today than in WP 4.0 – and with the addition of nearly 1000 tests. Score!) One of the tools I use to track down problematic tests is John Kary’s excellent phpunit-speedtrap, which adds a listener to each test run, and produces a report of tests whose running time exceeds a configurable threshhold. phpunit-speedtrap is designed to be used as a Composer dependency, but this is not currently convenient or necessary for the purposes of working with WP/BP (for one thing, I’m the only person doing it). Here’s how I’ve rigged it up to run locally:
- Grab a copy of the listener class from Github https://github.com/johnkary/phpunit-speedtrap/blob/master/src/JohnKary/PHPUnit/Listener/SpeedTrapListener.php. I chose to remove the PHP namespacing, but you can do as you wish. Save it somewhere – I put it at
~/.speed-trap-listener.php
so that I can use it with all projects. - WP and BP ship with a
phpunit.xml.dist
config file. The.dist
extension means that you can run your ownphpunit.xml
alongside ofphpunit.xml.dist
– PHPUnit will prefer the non-dist version if available, while WP and BP’s version control config will ignore it. Copyphpunit.xml.dist
tophpunit.xml
and add the following block:
[code language=”xml”]
250
Change theslowThreshold
and filepath to whatever you’d like. - Run
phpunit
. You’ll see something like this:
Keep on shavin’!
I’m enjoying buddypress… I’m using it to make a kind of digital legacy vault. It’s called Passed2You.com if you want to check it out. I’m not nearly as adept as you or your peers, but things have been working pretty smoothly for me using the system and I think that says something about how well it’s built. I found your site while looking for a way to email users from groups. Wanted to take a minute to say thanks for all the hard work.