This package builds upon the VT100.jl package to provide automated testing of terminal based application. Both plain text and formatted output is supported. Each test consists of
- The system under test (specified as a callback)
- A file specifying the expected output
- A series of input prompts
The main interface is the automated_test
function, which takes these three
components as arguemnts. There is also the create_automated_test
function,
which has the same interface, but will create the output file rather than
verifying against it. The operation of the test is fairly simple:
- An input is popped from the list of inputs
- The input is provided to the system under test
- The system under test is allowed to process the input until the system is done processing the input and has started blocking until new input is available
- The output that the system writes is compared to the output file.
- Repeat
Consider the following example:
TerminalRegressionTests.automated_test(
joinpath(thisdir,"TRT.multiout"),
["Julia\n","Yes!!\n"]) do emuterm
print(emuterm, "Please enter your name: ")
name = strip(readline(emuterm))
print(emuterm, "\nHello $name. Do you like tests? ")
resp = strip(readline(emuterm))
@assert resp == "Yes!!"
end
Note that the callback gets an emuterm
as an argument. This is an emulated
VT100 terminal and supports the usual operation. Note that this terminal is the
view from the program under test (i.e. reads from this terminal will obtain
the specified input data).