Skip to content

Commit 2443cb5

Browse files
committed
doc: notice do not create instance without New function.
1 parent c5ef1b2 commit 2443cb5

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

assertion.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ import (
55
)
66

77
// Assertion is the extension of the Go builtin `testing.T`.
8+
//
9+
// Please do not create an Assertion instance without the New function, every assertion function
10+
// will panic if no inner testing.T set.
811
type Assertion struct {
912
*testing.T
1013
}

assertion_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,14 @@ func TestNewAssertion(t *testing.T) {
1616
})
1717
}
1818

19+
func TestAssertionWithoutNew(t *testing.T) {
20+
Panic(t, func() {
21+
a := new(Assertion)
22+
23+
a.True(true)
24+
})
25+
}
26+
1927
func TestRun(t *testing.T) {
2028
a := New(t)
2129
isSubTestRun := false

0 commit comments

Comments
 (0)