https://github.com/alexbyk/ftest
ftest - Go fluent testing library and fluent testing http client
https://github.com/alexbyk/ftest
go golang test testing
Last synced: 9 months ago
JSON representation
ftest - Go fluent testing library and fluent testing http client
- Host: GitHub
- URL: https://github.com/alexbyk/ftest
- Owner: alexbyk
- License: mit
- Created: 2017-12-01T21:11:25.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-10-01T02:15:00.000Z (over 7 years ago)
- Last Synced: 2024-06-21T18:13:12.005Z (about 2 years ago)
- Topics: go, golang, test, testing
- Language: Go
- Homepage:
- Size: 265 KB
- Stars: 9
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://travis-ci.org/alexbyk/ftest)
# About
- `ftest` is a simple and easy to use go testing library with fluent design and exact failure messages.
- `fclient` is a simple http testing client, based on `ftest`.
# Documentation:
- [ftest](https://godoc.org/github.com/alexbyk/ftest)
- [fclient](https://godoc.org/github.com/alexbyk/ftest/fclient)
# Installation
```
go get -u github.com/alexbyk/ftest
```
# Usage
## ftest
```go
import (
"testing"
"github.com/alexbyk/ftest"
)
func TestFoo(t *testing.T) {
ftest.New(t).Eq(2, 2).
Contains("FooBarBaz", "Bar").
PanicsSubstr(func() { panic("Foo") }, "Foo")
}
```
You can also use your own label to group your test:
```go
ft := ftest.NewLabel(t, "MyLabel")
```
## fclient
```go
package app_test
import (
"fmt"
"net/http"
"testing"
"github.com/alexbyk/ftest/fclient"
)
type MyApp struct{}
func (app MyApp) ServeHTTP(w http.ResponseWriter, r *http.Request) {
w.Write([]byte(`{"foo": "bar"}`))
}
func Test_hello(t *testing.T) {
app := MyApp{}
cl := fclient.New(t, app)
cl.Get("/hello").CodeEq(200).
BodyContains("bar").
JSONEq(`{"foo":"bar"}`)
// using a response directly
res := cl.Get("/hello")
fmt.Println(res.Body)
}
```
# Copyright
Copyright 2018, [alexbyk.com](https://alexbyk.com)