Test assertion library


(Sebastian Hennebrueder) #1

Hi all,

I am learning Go and started to build a test assertion library which makes it a bit easier to write assertions on data.

https://github.com/laliluna/expectations

I would be delighted to get feedback on the code and the library itself.

Cheers Sebastian

import (
	"testing"
	"github.com/laliluna/expectations"
)

func TestDemo(t *testing.T) {
	eT := expectations.NewT(t)
	eT.ExpectString("Hello World").EndsWith("joe")

	values := []int{1, 2, 3}
	eT.ExpectSlice(values).Contains(1, 2, 55, 66)

expectations_test.go
--------------------
--- TestDemo in line 15: Expect Hello World to end with joe
--- TestDemo in line 17: Expect [1 2 3] to contain [1 2 55 66] but was missing [55 66]

--- FAIL: TestDemo (0.00s)