Skip to content

tevid/gohamcrest

Repository files navigation

gohamcrest - Hamcrest-style matchers for Golang testing

Build Status codebeat badge Coverage Status License GoDoc GitHub release

gohamcrest is Hamcrest-style matchers for Golang testing designed for easy to write test case.

Simple, readable and humanized, also easy to extended.

Help you become an excellent Golang Software Engineer is my believe.

Chinese doc

Installation

Install Go Env Getting Started .Once finished,then enjoy yourself.

gopm get github.com/tevid/gohamcrest -v -g

Or

go get -u github.com/tevid/gohamcrest

PS: Prefer Golang 1.6+

Features

  • Assert.List
  • Assert.Object
  • Assert.String

More feature please respect.

Usage

  • Assert equal
func TestEqual(t *testing.T) {
	Assert(t,2,Equal(2))
	Assert(t,"joe",Equal("joe"))
}
  • Assert not equal
func TestNotEqual(t *testing.T) {
	Assert(t,2,NotEqual(3))
	Assert(t,"joe",NotEqual("joe1"))
}

or

func TestNotEqual(t *testing.T) {
	Assert(t,2,Not(Equal(3)))
	Assert(t,"joe",Not(Equal("joe1")))
}

More usage,check test case please.More info check Wiki .

If you think the tool is good or have any problems,must let me know, contact me by email when feel free or create a issue.

Contribution

License

The project is licensed under the Apache 2 license.