I'm not a newbie since I've been programming on and off since 1983, but I only have real experience with scripting languages like Applescript, ARexx, HyperTalk and Bash.
I write scripts to automate data entry, batch process images and convert file formats. I dabble at Processing, Ruby and Python.
Most of the programs I write are under 200 lines with at most 10 functions. I wish to write larger, more capable programs in the future. I want to improve my practices to avoid creating fragile, unmaintainable messes. The programming environments that I work in (Script Editor.app and Text Wrangler.app) have no support for automated testing.
At the scale that I'm working now and writing procedural (not OO) code, is it appropriate to write unit tests, which I understand are:
short programs to test individual functions before combining them into a fully functioning larger program.
Are unit tests worthwhile compared to their cost when making programs at this scale?
Yes. Anything longer than zero lines can be unit tested - usually to good effect.
I'd look at the likelihood for regressions, not the number of lines of code. If your programs will live a long time and are likely to be refactored or otherwise modified, then unit test may make sense. If the code is throwaway or never likely to be modified, then unit tests probably won't be worthwhile.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With