So, I have this command line program binary (let's say its named ./prog) that I want to test. I want to use shunit2 as my testing framework. Unfortunately it asks the user for input. How can I test this? For example:
- start ./prog
- prog asks: Username:
- Check/assert that the string is the expected string (string should be accessible to shunit2)
- Now I need to specify an input, say John
- prog prints something in response, say it echoes John
- Check/assert that John is the expected output (string should be again accessible to shunit2)
How do I assert/verify/check this in shunit2, i.e. that the given input John results in the correct output string John?
I know there exist tools like 'expect' or 'expect-lite'. But, how would I test this using the shell only?
Or, how can I integrate expect or expect-lite so that I can verify the input using shunit2?