Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tylerstillwater/is
Is provides a quick, clean and simple framework for writing Go tests.
https://github.com/tylerstillwater/is
Last synced: 3 months ago
JSON representation
Is provides a quick, clean and simple framework for writing Go tests.
- Host: GitHub
- URL: https://github.com/tylerstillwater/is
- Owner: tylerstillwater
- License: mit
- Archived: true
- Created: 2015-03-28T16:04:13.000Z (over 9 years ago)
- Default Branch: v3
- Last Pushed: 2020-04-26T22:39:11.000Z (over 4 years ago)
- Last Synced: 2024-05-19T19:08:14.594Z (6 months ago)
- Language: Go
- Size: 49.8 KB
- Stars: 27
- Watchers: 1
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome - is - Is provides a quick, clean and simple framework for writing Go tests. (Go)
README
# is [![GoDev](https://img.shields.io/static/v1?label=godev&message=documentation&color=informational&style=plastic&&url=https://pkg.go.dev/github.com/tylerb/[email protected]?tab=doc)](https://pkg.go.dev/github.com/tylerb/is/[email protected]?tab=doc) [![Build Status](https://circleci.com/gh/tylerb/is/tree/v3.svg?style=shield&circle-token=94428439ffc6eda6471dc218471dab20985f444c)](https://circleci.com/gh/tylerb/is/tree/v3)
## Archived
`is` has been archived in favor of [Proof](https://github.com/tystil/proof)
-----------
Is provides a quick, clean and simple framework for writing Go tests.
## Installation
To install, simply execute:
```
go get -u github.com/tylerb/is/v3
```## Usage
```go
func TestSomething(t *testing.T) {
assert := is.New(t)expected := 10
actual, _ := awesomeFunction()
assert.Equal(actual, expected)
}
```If you'd like a bit more information when a test fails, you may use the `Msg()` method:
```go
func TestSomething(t *testing.T) {
assert := is.New(t)expected := 10
actual, details := awesomeFunction()
assert.Msg("actual details: %s", details).Equal(actual, expected)
}
```By default, any assertion that fails will halt termination of the test. If you would like to run a group of assertions
in a row, you may use the `Lax` method. This is useful for asserting/printing many values at once, so you can correct
all the issues between test runs.```go
func TestSomething(t *testing.T) {
assert := is.New(t)assert.Lax(func (lax Asserter) {
lax.Equal(1, 2)
lax.True(false)
lax.ShouldPanic(func(){})
})
}
```If any of the assertions fail inside that function, an additional error will be printed and test execution will halt.