https://github.com/gekorob/texp
Testing by Expectations simple mini-framework
https://github.com/gekorob/texp
expect go golang tdd test testing
Last synced: 9 months ago
JSON representation
Testing by Expectations simple mini-framework
- Host: GitHub
- URL: https://github.com/gekorob/texp
- Owner: gekorob
- License: mit
- Created: 2018-12-31T14:08:13.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-02-27T10:32:09.000Z (over 7 years ago)
- Last Synced: 2024-06-20T07:59:26.946Z (about 2 years ago)
- Topics: expect, go, golang, tdd, test, testing
- Language: Go
- Homepage:
- Size: 66.4 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# TEXP
[](https://goreportcard.com/report/github.com/gekorob/texp) [](http://godoc.org/github.com/gekorob/texp) [](https://travis-ci.org/gekorob/texp)
## Testing by Expectations simple mini-framework
Easy expectations based testing mini-framework inspired by the wonderful Mat Ryer ["is"](https://github.com/matryer/is) project, but for RSpec nostalgic like me.
This project is a working progress, so expect changes and more new things.
### Basic usage
Using Texp with default settings is very simple
```go
import (
...
"testing"
"github.com/gekorob/texp"
...
)
func TestSomething(t *testing.T) {
expect := texp.Expect(t)
expect(2 == 2).ToBeTrue()
}
func TestSomethingOther(t *testing.T) {
expect := texp.Expect(t)
expect(3).ToEqual(2)
}
```
### Instance configuration
With Texp you can change the default configuration for each test, setting an output different from the StdOut or an alternative style (implementing the appropriate interface)
```go
import (
...
"strings"
"testing"
"github.com/gekorob/texp"
"github.com/gekorob/texp/conf"
...
)
func TestSomething(t *testing.T) {
var b strings.Builder
yourStyle := ....
expect := texp.Expect(t, conf.OutputTo(&b, conf.StyleWith(yourStyle))
expect(1 == 1).ToBeTrue()
}
```