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?
How to test Ruby scripts which offer functionality between runs?
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.
© 2022 - 2024 — McMap. All rights reserved.