Skip to content
This repository has been archived by the owner on Dec 5, 2023. It is now read-only.
/ golang-assert Public archive

Two simple functions for soft unit test assertions in Go.

License

Notifications You must be signed in to change notification settings

stfsy/golang-assert

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Assert

Build Status

Two simple functions for soft unit test assertions in Go.

Yes, the Go FAQ states the following:

[..] testing frameworks tend to develop into mini-languages of their own, with conditionals and controls and printing mechanisms, but Go already has all those capabilities; why recreate them? We'd rather write tests in Go; it's one fewer language to learn and the approach keeps the tests straightforward and easy to understand.

But unit tests should be clean too, right? :)

Both Assertions are soft assertions. Failing tests will only be reported to the console via t.Errorf().

Assert equal

var paul = Person{
	name: "Paul",
	age:  32}

func TestEqual(t *testing.T) {
	assert.Equal(t, paul, paul, "Paul equals paul")
}

Assert not equal

var paul = Person{
	name: "Paul",
	age:  32}

var peter = Person{
	name: "Peter",
	age:  21}

func TestNotEqual(t *testing.T) {
	assert.NotEqual(t, paul, peter, "Paul does not equal peter")

Installation

go get github.com/stfsy/golang-assert

License

This project is distributed under the MIT license.

About

Two simple functions for soft unit test assertions in Go.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages