You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+20Lines changed: 20 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -22,12 +22,17 @@ This library provided assertion functions to verify the equality of values, or a
22
22
23
23
```go
24
24
funcTestExample(t *testing.T) {
25
+
// var actual
26
+
// var expect
27
+
25
28
// assert equality
26
29
assert.DeepEqual(t, actual, expect)
27
30
28
31
// assert inequality
29
32
assert.NotDeepEqual(t, actual, expect)
30
33
34
+
// var object
35
+
31
36
// assert for nil
32
37
assert.Nil(t, object)
33
38
@@ -56,6 +61,21 @@ func TestPanic(t *testing.T) {
56
61
}
57
62
```
58
63
64
+
For every assertion functions, it also provided `XXXNow` functions to stop the execution.
65
+
66
+
```go
67
+
funcTestExample(t *testing.T) {
68
+
// var actual
69
+
// var expect
70
+
71
+
// The following line will set the test result to fail and stop the execution
72
+
assert.DeepEqualNow(t, actual, expect)
73
+
74
+
// The following lines will never execute if they are not deep equal.
75
+
// ...
76
+
}
77
+
```
78
+
59
79
Every assertion will not terminate the testing workflow. However, they'll return an error if the verification failed, and you can check the return value to get the verification result.
0 commit comments