ftest - Go fluent testing library and fluent testing http client
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
fclient
internal
.travis.yml
CHANGELOG.md
LICENSE
Readme.md
demo.gif
ftest.go
ftest_test.go

Readme.md

Build Status

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:

Installation

go get -u github.com/alexbyk/ftest

Usage

ftest

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:

ft := ftest.NewLabel(t, "MyLabel")

fclient

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