Hi,
tl;dr Are there any existing end-to-end testing libraries for CLI applications? Specifically, what I'm looking for is a library that makes it easy to test that "running this command should produce this output" without fear that a buggy application could corrupt the filesystem.
Background:
I have a few CLI applications (written in Go) that are becoming quite complex. I'd like to add some end-to-end and integration tests to ensure that I don't accidentally break existing functionality while refactoring or adding new features. The CLI applications can make arbitrary changes to the filesystem and I don't want it to be possible for a buggy application to leave any trace on the filesystem after the test terminates. I want something like:
- Easy setup of a chroot environment or Docker container or similar with my Go binary copied somewhere into $PATH.
- Easy way to specify what commands should be run.
- Easy way to write tests that check exit codes and ensure that the stdout/stderr output matches a string or regular expression.
- Automatic tidy-up of the chroot/container after the test is complete.
- Scripted in Go and integrated with Go's testing package, of course :)
I don't need controls over CPU usage or networking as my applications are not CPU bound and do not need network access, but I wouldn't complain if they existed.
I know about
github.com/ory/dockertest which is fantastic for writing integration tests with third-party services but not set up for testing your own applications.
Do you know of any existing libraries that implement this sort of functionality?
Many thanks,
Tom