Skip to content
/ texp Public

Testing by Expectations simple mini-framework

License

Notifications You must be signed in to change notification settings

gekorob/texp

Repository files navigation

TEXP

Go Report Card GoDoc Build Status

Testing by Expectations simple mini-framework

Easy expectations based testing mini-framework inspired by the wonderful Mat Ryer "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

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)

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()
}

About

Testing by Expectations simple mini-framework

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published