Automated tests are such a joy. I have at times deleted tests but I've never regretted writing them. Today was a good reminder.
First the good news... today I made 2 first Drupal 10 compatible releases - NG Lightbox and Colorbox Load. Thanks Benjy for the approval of my being a maintainer for LG Lightbox! Part of that was committing patches that had already been reviewed - which went swimmingly. Next however, the tests for NG Lightbox were very out of date and couldn't run with Drupal 9 or 10. So before I could be happy making that stable release I had to have those tests running.
Which is predictably given that this article is talking about automated testing is where I ran into a few issues. Had fix significant old code which was fairly boring albeit important. Then I ran into a continuous issue of one of the tests emitting a deprecation error on PHP 8.1. Complaining that null can't be passed as the first argument of preg_quote. After a few passes I was confident it wasn't from code under my control. Promptly tracked it down to a piece of core code. PathMatcher::getFrontPagePath claims in its docblock to return a string. However it can also return null. Which is then used in other core code that presumes it is a string.
End result of today's excursion into automated tests?
- Higher confidence in module stability
- Less chance of future changes breaking everything
- And today's unexpected bonus: a new core issue with patch ready for review
- Login or register to be able to comment. You can log in with various social/3rd party accounts.