A testing library focused on turning failure into success, actually
.
- Builder interface to make test code obvious
- Consistent method name to reduce things you have to remember
- Specific fail report to save your time
- There are helpers to see details of a failure
package main // https://go.dev/play/p/d57qXq3q6dl
import (
"testing"
a "github.com/bayashi/actually"
)
func Test(t *testing.T) {
love, err := getLove()
// Assert 1 object
a.Got(err).NoError(t)
a.Got(love).True(t)
// Assert 2 objects
heart := &love
body := heart
a.Got(heart).Expect(body).SamePointer(t)
}
func getLove() (bool, error) {
return true, nil
}
- True, False, Nil, NotNil, NoError
- Same, SameConvertibleNumber, SamePointer, SameType
- Cmp, CmpAllowUnexported, (CmpOpt)
- NotSame, NotSameConvertibleNumber, NotSamePointer, NotSameType
- Panic, PanicMessage, NoPanic
- Match, NotMatch
- Len
Here is a Wiki of full API documentation.
actually
will help you with evident fail report:
builder_test.go:133:
Test name: TestTree
Trace: /path/to/src/github.com/bayashi/goverview/builder_test.go:133
Fail reason: Not same
Expected: Dump: "\n┌ 001/\n├── .gitignore\n├── LICENSE: License MIT\n├── go.mod: go 1.18\n└───+ main.go: main\n Func: X\n const: X\n"
Actually got: Dump: "\n┌ 001/\n├── .gitignore\n├── LICENSE: License MIT\n├── go.mod: go 1.19\n└──* main.go: main\n Func: X\n Const: X\n"
Diff Details: --- Expected
+++ Actually got
@@ -4,6 +4,6 @@
├── LICENSE: License MIT
-├── go.mod: go 1.18
-└───+ main.go: main
+├── go.mod: go 1.19
+└──* main.go: main
Func: X
- const: X
+ Const: X
Raw Expect: ---
┌ 001/
├── .gitignore
├── LICENSE: License MIT
├── go.mod: go 1.18
└───+ main.go: main
Func: X
const: X
---
Raw Got: ---
┌ 001/
├── .gitignore
├── LICENSE: License MIT
├── go.mod: go 1.19
└──* main.go: main
Func: X
Const: X
actually
has the Debug("label", any_variable)
method to show additional data only in fail report.
Like below, src
variable will be dumped nicely only on fail.
res := someFunc(src)
actually.Got(res).Debug("src", src).True(t)
go get github.com/bayashi/actually
MIT License
Dai Okabayashi: https://github.com/bayashi
Inspired by: