Skip to content
generated from dogmatiq/template-go

🚧 Markdown-based golden-file tests for Go.

License

Notifications You must be signed in to change notification settings

dogmatiq/aureus

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Aureus

A test runner for executing "golden file" tests in Go.

Documentation Latest Version Build Status Code Coverage

What is a golden file?

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.

What does Aureus do?

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.

Flat files

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.

Markdown documents

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.

About

🚧 Markdown-based golden-file tests for Go.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •