Categorygithub.com/tobbstr/testa
repository
0.0.0-20210723215208-77324e02e7b2
Repository: https://github.com/tobbstr/testa.git
Documentation: pkg.go.dev

# Packages

No description provided by the author

# README

testa

Readable non-ambiguous testing library for Golang

assert package

Provides assert functionality.

There are two kinds of asserts. Both mark the function under test as having failed, but one stops the execution of the test (fatal asserts) and the other one allows it to continue.

Non-fatal assert function construction

func TestExampleFunc(t *testing.T) {
    // Constructs the non-fatal assert function
    assert := testa.New(t)
}

Fatal assert function construction

func TestExampleFunc(t *testing.T) {
    // Constructs the fatal assert function
    require := testa.NewFatal(t)
}

Usage

func TestExampleFunc(t *testing.T) {
    want := 5
    got := ExampleFunc()

    // assert got value equals want
    assert(got).Equals(want)
}
func TestExampleFunc(t *testing.T) {
    got, err := ExampleFunc()

    // assert err value is nil
    require(err).IsNil()
    // assert got value is not nil
    require(got).IsNotNil()
}

Licence

This project is licensed under the terms of the MIT license.

Sources