Popularity
0.8
Stable
Activity
10.0
Stable
7
1
1

Programming language: Go
License: BSD 3-clause "New" or "Revised" License
Tags: Testing     Testing Frameworks    

diff alternatives and similar packages

Based on the "Testing Frameworks" category.
Alternatively, view diff alternatives based on common mentions on social networks and blogs.

Do you think we are missing an alternative of diff or a related project?

Add another 'Testing Frameworks' Package

README

diff

Coverage Status

diff contains git-style diff generation helpers, particularly useful for tests.

Install

go get oss.terrastruct.com/diff

Usage

diff.Strings

Tired of ugly "expected" vs "actual" test outputs? diff.Strings gives you git-style diffs:

exp := ...
actual := YourFunction()
diffs, err := diff.Strings(exp, actual)
if ds != "" {
  t.Fatalf("unexpected result: %s", ds)
}

diff.Testdata

Sometimes the expected is not a simple string to include in your test. Sometimes it's a long JSON blob that you want to compare. Use diff.Testdata to easily store and compare test results to saved files.

err := diff.Testdata("test_results", actual)
if err != nil {
  t.Fatal(err)
}

An example of this is the first image in this README. You can then choose to accept the new actual by rerunning the test with TESTDATA_ACCEPT=1 environment variable.

Assert

You can also use diff.AssertJSONEq and diff.AssertStringEq in testing environments to shorthand the above "if fail then Fatal" code.