A "golden file" is a file that represents the expected output of some test. When the test is executed, the output of the system under test is compared to the content of the golden file — if they differ, the test fails.
Aureus recursively scans directories for golden file tests expressed either as
flat files, or as code blocks within Markdown documents. By default it scans the
testdata
directory within the current working directory.
Files with names matching the <group>.input[.<extension>]
and
<group>.output[.<extension>
patterns are treated as test inputs and outputs,
respectively.
For each pair of input and output files with the same <group>
prefix, a
user-defined function is invoked. The function must produce output that matches
the content of the output file, otherwise the test fails.
The run_test.go
illustrates how to use Aureus to execute the flat-file tests
in the testdata
directory.
As an alternative to (or in combination with) flat-file tests, Aureus can load inputs and outputs from fenced code blocks within Markdown documents.
Code blocks annotated with the au:input
or au:output
attribute are treated
as a test input or output, respectively. The au:group
attribute is used to
group the inputs and outputs.
This file is itself an example of a Markdown-based test. It confirms the behavior of a basic JSON pretty-printer. Given this unformatted JSON value:
{ "one": 1, "two": 2 }
We expect our formatter function to produce the following output:
{
"one": 1,
"two": 2
}
View the README source to see how the code blocks are annotated for use with
Aureus, and run_test.go
to see how to execute the
tests.