should is a single-file program to test command-line applications on Unix-like systems. It checks the standard output, or possibly another file, and parses for exact or regular expressions, possibly while counting them and checking their number of occurrences.
It outputs reports in .tap format
and in JUnit-like XML.
should is written in Python with no external dependencies except from Python >= 3.4
and is intended to work on any command-line application.
Should your application outputs something, you can test it!
A test file is a text file:
> cat hello.should# A .should file launches any command it encounters. echo "hello, world" # Lines containing a `:` are test lines. # The `test expression` is what is found at the right of the `:`. # Here 'world' should be found on stdout, at least in one line. :world # What is at the left of the `:` are modifiers. # One can specify the exact number of lines where the test expression has to appear. # 'moon' should not be found on stdout. 0:moon
Launching should on test files performs the tests:
> ./should demo/hello.should==> ok - ok:2 - total:2 tests
Should can check occurrences counts, look for regular expressions, use variables, filter tests, parse json data, check exit codes... See the documentation and the gitlab.
Download should 3.0.0 (2020-07-10)