6

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?

sutch
  • 1,225
  • 1
  • 13
  • 28

1 Answers1

1

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.

Sławosz
  • 11,187
  • 15
  • 73
  • 106