Skip to content
No description, website, or topics provided.
Go
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
reporters
utils
.gitignore
.travis.yml
LICENSE.md
README.md
TODO.md
approval_name.go make sure we get the right path for go examples too Jun 20, 2018
approvals.go
approvals_test.TestReporterFromSetup.approved.txt
approvals_test.TestVerifyAllCombinationsFor1.approved.txt TestVerifyAllCombinations Jul 13, 2016
approvals_test.TestVerifyAllCombinationsFor2.approved.txt
approvals_test.TestVerifyAllCombinationsFor9.approved.txt
approvals_test.TestVerifyAllCombinationsForSkipped.approved.txt
approvals_test.TestVerifyArray.approved.txt
approvals_test.TestVerifyArrayBadArray.approved.txt
approvals_test.TestVerifyArrayEmptyArray.approved.txt
approvals_test.TestVerifyArrayTransformation.approved.txt
approvals_test.TestVerifyBadJSONBytes.approved.json
approvals_test.TestVerifyBadXMLBytes.approved.xml
approvals_test.TestVerifyBadXMLStruct.approved.xml
approvals_test.TestVerifyJSONBytes.approved.json
approvals_test.TestVerifyJSONStruct.approved.json
approvals_test.TestVerifyMap.approved.txt
approvals_test.TestVerifyMapBadMap.approved.txt
approvals_test.TestVerifyMapEmptyMap.approved.txt
approvals_test.TestVerifyStringApproval.approved.txt
approvals_test.TestVerifyXMLBytes.approved.xml
approvals_test.TestVerifyXMLStruct.approved.xml
approvals_test.go testable example Jun 19, 2018
combination_approvals.go
examples_helper_test.go
examples_test.ExampleVerifyAllCombinationsFor2.approved.txt
examples_test.ExampleVerifyAllCombinationsFor2WithSkip.approved.txt
examples_test.ExampleVerifyString.approved.txt
examples_test.go
namer_test.go
reporter_test.go

README.md

ApprovalTests.go

ApprovalTests for go

GoDoc Go Report Card Coverage Status Build Status

Golden master Verification Library

ApprovalTests allows for easy testing of larger objects, strings and anything else that can be saved to a file (images, sounds, csv, etc...)

Examples

In Project

Note: ApprovalTests uses approvaltests to test itself. Therefore there are many examples in the code itself.

JSON

VerifyJSONBytes - Simple Formatting for easy comparison. Also uses the .json file extension

func TestVerifyJSON(t *testing.T) {
	jsonb := []byte("{ \"foo\": \"bar\", \"age\": 42, \"bark\": \"woof\" }")
	VerifyJSONBytes(t, jsonb)
}

Matches file: approvals_test.TestVerifyJSON.received.json

{
  "age": 42,
  "bark": "woof",
  "foo": "bar"
}

Reporters

ApprovalTests becomes much more powerful with reporters. Reporters launch programs on failure to help you understand, fix and approve results.

You can make your own easily, here's an example You can also declare which one to use. Either at the

Method level

r := UseReporter(reporters.NewIntelliJ())
defer r.Close()

Test Level

func TestMain(m *testing.M) {
	r := UseReporter(reporters.NewBeyondCompareReporter())
	defer r.Close()

	os.Exit(m.Run())
}
You can’t perform that action at this time.