4 ms·
I can't help but appreciate the irony of a link titled "Where unit testing fails" leading to a WordPress database connection error.
by chrislloyd 15y ago
I can't help but appreciate the irony of a link titled "Where unit testing fails" leading to a WordPress database connection error.
- hmemcpy 15y agoSorry, my hosting is probably not... used to any traffic :) Should be ok now...
- rimantas 15y agoSo you think unit tests would help with that?
- lhnz 15y agoThat's the point. Most unit tests wouldn't stop this kind of problem. ;)
- deleted 15y ago[deleted]
- hmemcpy 15y agoSorry for the late reply. That's an interesting question - would a unit test prevent this error? To answer this, let's consider what happened: the database didn't respond in an appropriate way, and probably returned an error. I'm not exactly sure what exact error was displayed, but WordPress has caught this situation, and handled it the best it could - displaying a proper error. I would write a unit test for this exact scenario - using a fake (mock) object, simulate the database timeout, and make sure that the error was caught and handled appropriately. Other then that there's no real other way to gracefully recover.