What's a good method for unit testing which test a script's ability to maintain correct data between executions--after a script is terminated with Ctrl-C and then re-run? Are there any tests for existing modules or scripts that do something similar that could be reviewed for best practices?
Use library like http://avdi.org/devblog/2010/07/19/greenletters-painless-automation-and-testing-for-command-line-applications/ or expect, run, terminate and rerun your program, and check if it behaves correctly. Good practice is to design program as independent modules, each well tested, to minimize integration test in console.
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