https://github.com/deeprave/go-testutils
https://github.com/deeprave/go-testutils
Last synced: 4 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/deeprave/go-testutils
- Owner: deeprave
- License: mit
- Created: 2023-02-04T06:30:07.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-03-05T09:38:47.000Z (over 3 years ago)
- Last Synced: 2024-06-20T11:16:37.892Z (almost 2 years ago)
- Language: Go
- Size: 3.91 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Test support functions for golang
## Description
The `test` package contains a number of easily comprehensible utility functions that abbreviate
a lot of the boilerplate code associated with Go unit testing.
`test.SetErrorsFatal(bool)` can be called to determine whether test failures are fatal (default = true).
## Functions
The following functions resemble simple assertions that return a `bool` type indicate whether the tested
value succeeds.
This allows for immediate exit from the test function on test failure.
### Equality
`ShouldBeEqual(*testing.T, interface{}, interface{}, ...options) bool`
: compares two values which are expected to be identical via deep comparison
`ShouldNotBeEqual(*testing.T, interface{}, interface{}, ...options) bool`
: compares two values which are expected not to be identical via deep comparison
### True/False
`ShouldBeTrue(*testing T, bool, format, ...args) bool`
: tests if the result of an expression is true
`ShouldBeFalse(*testing T, bool, format, ...args) bool`
: tests if the result of an expression is false
### Nil
`ShouldBeNil(*testing T, interface{}, format, ...args) bool`
: tests if a value is nil
`ShouldNotBeNil(*testing T, interface{}, format, ...args) bool`
: tests if a value is not nil
### In Array
`ShouldBeInArray(*testing.T, []V, V, ...options) bool`
: tests if a value is in the provided array
`ShouldNotBeInArray(*testing.T, []V, V, ...options) bool`
: tests if a value is not in the provided array
### Error
`ShouldBeError(*testing.T, error, format, ...args) bool`
: error is expected to be non-null
`ShouldBeNoError(*testing.T, error, format, ...args) bool`
: error is expected to be null