TestaRossa is a simple utility on top of Go's standard testing library that prints the full/path/to/the/source/file/of/the/unit_test.go:line of a failed assertion, which in VSCode is a clickable link. Unlike t.Log, output is printed using fmt.Printf during the execution of the test rather than at its conclusion.
TestaRossa supports a functional pattern:
func TestMe(t *testing.T) {
neo := 1999
testarossa.Equal(t, 1, neo, "You are not the %d", 1)
err := errors.New("This is bad")
testarossa.NoError(t, err)
html := `<html><body><div class="banner">Hello, <b>World</b>!</div></body></html>`
testarossa.HTMLMatch(t, html, "DIV.banner", "^World$")
droids := 1234
testarossa.FailIf(t, droids != 0, "These are not the droids you are looking for")
err = errors.New("This is really bad")
testarossa.FatalIfError(t, err)
}as well as a more object-oriented pattern:
func TestMe(t *testing.T) {
assert := testarossa.For(t)
neo := 1999
assert.Equal(1, neo, "You are not the %d", 1)
err := errors.New("This is bad")
assert.NoError(err)
result, err := doSomething(param)
assert.Expect(err, nil, result, 1234)
html := `<html><body><div class="banner">Hello, <b>World</b>!</div></body></html>`
assert.HTMLMatch(html, "DIV.banner", "^World$")
}Example test output:
--- FAIL: TestMe
/my_projects/github.com/microbus-io/testarossa/my_test.go:10
Expected '1', actual '1999'
You are not the 1
--- FAIL: TestMe
/my_projects/github.com/microbus-io/testarossa/my_test.go:12
Expected no error
This is bad
--- FAIL: TestMe (0.00s)
FAIL
FAIL github.com/microbus-io/testarossa 0.173s
FAIL
TestaRossa is licensed by Microbus LLC under the Apache License 2.0.
