Package golden helps writing golden tests.
A golden test (a.k.a. gold master or approval test) consists of pairs of files: given test input and expected output (the gold master).
This package is mainly intended to be used with the standard Go testing library. You can still use it without. It is not intended to be a full testing framework.
go get github.com/nochso/golden
See godoc for API docs and examples.
It's important that golden files are easy to read, edit and diff. Usually it's
enough to add a String() string
method or more detailed TestString
,
debugString
, etc. to dump the data you want to compare in a human readable
way.
Any methods that could fail and have access to T (as in testing.T
)
will call T.Error(err)
. If T is nil, log.Println(err)
is called instead.
This mainly concerns Case and File structs and any methods mentioning
failing.
All notable changes to this project will be documented in CHANGELOG.md
This project adheres to Semantic Versioning.
This package is released under the MIT license.