When I release the new library I’m also hoping to release all the tests for the library classes.
I had written quite a few tests for the library before the re-structure but I didn’t have anywhere near as much coverage as I would have liked. I’ve since made it a point to write tests for each libary class as I move them over to the new system.
So far this has been a very useful exercise, particularly with my form classes. I’d always planned on making a few minor changes to the form classes and form builder but not quite as many as I have. The changes came about because as I was writing my tests for the new functionality, adding decorators, I noticed a line of code that wasn’t really necessary, with my tests it was trivial to decide on a new api for the classes and then modify my code to ensure everything worked, after a couple of minor tweaks to the code it was so reassuring to see that the 18 tests for my text input class still worked.
Why am I writing this? Well the main reason it that I believe four years ago when I started writing tests I didn’t realise the main benefit. Back then I mistakenly thought that the main benefit of tests was to ensure that the code worked as intended as is and after any changes. Now, to me the main benefit of tests is in creating the best api for your classes.
Not rocket science I know but sometimes, like OOP you have to make the connection yourself.