Skip to content
/ ftest Public

ftest - Go fluent testing library and fluent testing http client

License

Notifications You must be signed in to change notification settings

alexbyk/ftest

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

ftest - Go fluent testing library and fluent testing http client

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages