Popularity
0.5
Stable
Activity
0.0
Stable
7
0
0
Description
test environment
Programming language: Go
Latest version: v1.0
assertion alternatives and similar packages
Based on the "Testing" category.
Alternatively, view assertion alternatives based on common mentions on social networks and blogs.
-
Testify
A toolkit with common assertions and mocks that plays nicely with the standard library -
chromedp
A faster, simpler way to drive browsers supporting the Chrome DevTools Protocol. -
GoConvey
Go testing in the browser. Integrates with `go test`. Write behavioral tests in Go. -
gotests
Automatically generate Go test boilerplate from your source code. -
realize
Realize is the #1 Golang Task Runner which enhance your workflow by automating the most common tasks and using the best performing Golang live reloading. -
selenoid
Selenium Hub successor running browsers within containers. Scalable, immutable, self hosted Selenium-Grid on any platform with single binary. -
hoverfly
Lightweight service virtualization/API simulation tool for developers and testers -
go-vcr
Record and replay your HTTP interactions for fast, deterministic and accurate tests -
playwright-go
Playwright for Go a browser automation library to control Chromium, Firefox and WebKit with a single API. -
testfixtures
Ruby on Rails like test fixtures for Go. Write tests against a real database -
gnomock
Test your code without writing mocks with ephemeral Docker containers 📦 Setup popular services with just a couple lines of code ⏱️ No bash, no yaml, only code 💻 -
counterfeiter
A tool for generating self-contained, type-safe test doubles in go -
Mmock
Mmock is an HTTP mocking application for testing and fast prototyping -
cdp
Package cdp provides type-safe bindings for the Chrome DevTools Protocol (CDP), written in the Go programming language. -
goc
A Comprehensive Coverage Testing System for The Go Programming Language -
embedded-postgres
Run a real Postgres database locally on Linux, OSX or Windows as part of another Go application or test -
testza
Full-featured test framework for Go! Assertions, fuzzing, input testing, output capturing, and much more! 🍕 -
gotest.tools
A collection of packages to augment the go testing package and support common patterns. -
go-testdeep
Extremely flexible golang deep comparison, extends the go testing package, tests HTTP APIs and provides tests suite
Developer Ecosystem Survey 2022
Take part in the Developer Ecosystem Survey 2022 by JetBrains and get a chance to win a Macbook, a Nvidia graphics card, or other prizes. We’ll create an infographic full of stats, and you’ll get personalized results so you can compare yourself with other developers.
Promo
surveys.jetbrains.com
Do you think we are missing an alternative of assertion or a related project?
README
Should
lightweight test environment
Install
go get github.com/maprost/should
Supported methods
should.BeEqual
(t
,element
,element
) -> check if two elements are equalshould.NotBeEqual
(t
,element
,element
) -> check if two elements are not equalshould.BeNil
(t
,element
) -> check if an element it nilshould.NotBeNil
t,
(element
) -> check if an element is not nilshould.BeTrue
(t
,element
) -> check if an element istrue
should.BeFalse
(t
,element
) -> check if an element isfalse
should.HaveLength
(t
,collection
,length
) -> (only forarray
/slice
/map
) check the length of the collectionshould.Contain
(t
,collection
,element
) -> (only forarray
/slice
/map
/string
) check if the collection contains the elementshould.NotContain
(t
,collection
,element
) -> (only forarray
/slice
/map
) check if the collection contains not the elementshould.BeSimilar
(t
,collection
,collection
) -> (only forarray
/slice
) check if the two collections contains the same elementsshould.NotBeSimilar
(t
,collection
,collection
) -> (only forarray
/slice
) check if the two collections contains at least one different elementshould.Fail
-> stops the tests with the given error message
Usage
Please look into the test files to see the possibilities. For the first look here some examples:
func TestSimple(t *testing.T) {
should.BeEqual(t, 1, 1, "should be equal")
should.BeNil(t, nil)
should.NotBeNil(t, 1)
should.BeTrue(t, true)
should.BeFalse(t, false)
should.NotBeEqual(t, 1, 2)
should.NotBeEqual(t, 1.0, 1)
should.NotBeEqual(t, int64(1), int32(1))
}
func TestDataStructures(t *testing.T) {
should.HaveLength(t, []int{1, 2, 3}, 3)
should.HaveLength(t, [3]int{1, 2, 3}, 3)
should.HaveLength(t, map[int]int{1: 1, 2: 3, 3: 5}, 3)
should.BeEqual(t, []int{1, 2, 3}, []int{1, 2, 3})
should.NotBeEqual(t, []int{1, 2, 3}, []int{3, 2, 1})
should.BeSimilar(t, []int{1, 2, 3}, []int{3, 2, 1})
should.BeSimilar(t, []int{1, 2, 3}, [3]int{3, 2, 1})
should.NotBeSimilar(t, []int{1, 2, 3}, [3]int{3, 2, 4})
should.NotBeSimilar(t, []int{1, 2, 3}, []int{2, 3, 4, 1})
should.NotBeEqual(t, []int{1, 2, 3}, [3]int{1, 2, 3})
should.BeEqual(t, [3]int{1, 2, 3}, [3]int{1, 2, 3})
should.Contain(t, []int{1, 2, 3}, 2)
should.NotContain(t, []int{1, 2, 3}, 4)
should.Contain(t, [3]int{1, 2, 3}, 3)
should.NotContain(t, [3]int{1, 2, 3}, 4)
should.BeEqual(t, map[int]string{1: "1", 2: "2", 3: "3"}, map[int]string{1: "1", 2: "2", 3: "3"})
should.NotBeEqual(t, map[int]string{1: "1", 3: "3"}, map[int]string{1: "1", 4: "4"})
should.BeEqual(t, map[int]string{1: "1", 3: "3"}, map[int]string{3: "3", 1: "1"})
should.Contain(t, map[int]string{1: "11", 3: "33"}, "33")
should.NotContain(t, map[int]string{1: "11", 3: "33"}, "55")
}
func TestStructs(t *testing.T) {
type Post struct {
Id int64
Msg string
}
p1 := Post{Id: 12, Msg: "New"}
p2 := Post{Id: 12, Msg: "New"}
p3 := Post{Id: 12, Msg: "Old"}
should.BeEqual(t, p1, p1)
should.BeEqual(t, p1, p2)
should.BeEqual(t, &p1, &p2)
should.NotBeEqual(t, p1, p3)
should.NotBeEqual(t, p1, &p1)
should.BeEqual(t, []Post{p1}, []Post{p2})
should.NotBeEqual(t, []Post{p1}, []Post{p3})
should.Contain(t, []Post{p1, p2, p3}, p3)
should.Contain(t, []*Post{&p1, &p2, &p3}, &p3)
should.Contain(t, []*Post{&p1, &p3}, &p2)
should.NotContain(t, []Post{p1, p2}, p3)
should.NotContain(t, []Post{p1}, 22)
should.NotContain(t, []Post{}, p1)
should.NotContain(t, []*Post{&p1, &p2}, &p3)
should.NotContain(t, []*Post{&p1, &p2}, p2)
should.BeEqual(t, [1]Post{p1}, [1]Post{p2})
should.NotBeEqual(t, [1]Post{p1}, [1]Post{p3})
should.Contain(t, [2]Post{p1, p2}, p2)
should.Contain(t, [3]*Post{&p1, &p2, &p3}, &p3)
should.Contain(t, [2]*Post{&p1, &p3}, &p2)
should.NotContain(t, [2]Post{p1, p2}, p3)
should.NotContain(t, [1]Post{p1}, "blob")
should.NotContain(t, [0]Post{}, p1)
should.NotContain(t, [2]*Post{&p1, &p2}, &p3)
should.NotContain(t, [2]*Post{&p1, &p2}, p1)
should.BeEqual(t, map[int]Post{1: p1}, map[int]Post{1: p2})
should.NotBeEqual(t, map[int]Post{1: p1}, map[int]Post{1: p3})
should.NotBeEqual(t, map[int]Post{1: p1}, map[int]Post{2: p1})
should.Contain(t, map[int]Post{1: p1, 2: p2}, p2)
should.Contain(t, map[int]*Post{1: &p1, 2: &p2}, &p2)
should.NotContain(t, map[int]Post{1: p1, 2: p2}, p3)
should.NotContain(t, map[int]Post{1: p1}, "blob")
should.NotContain(t, map[int]Post{}, p1)
should.NotContain(t, map[int]*Post{1: &p1}, p1)
}
Output
The output of a failed test shows you the actual and expected value and a stacktrace.
should.go:75: Not equal:
actual: 1(float64)
expected: 1(int)
/.../src/github.com/maprost/should/failing_test.go:12 +0xd1
/usr/local/go/src/testing/testing.go:657 +0x96
/usr/local/go/src/testing/testing.go:697 +0x2ca