-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathconveyz_test.go
More file actions
72 lines (64 loc) · 1.81 KB
/
conveyz_test.go
File metadata and controls
72 lines (64 loc) · 1.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
package examples_test
import (
"fmt"
"testing"
"ezpkg.io/colorz"
. "ezpkg.io/conveyz"
"ezpkg.io/conveyz/examples"
)
func Test(t *testing.T) {
Convey("Start", t, func() {
s := "[0]"
defer func() { fmt.Printf("\n%s\n", s) }()
add := func(part string) {
s = examples.AppendStr(s, part)
}
Convey("Test 1:", func() {
add(" → [1]")
Ω(s).To(Equal("[0] → [1]"))
Convey("Test 1.1:", func() {
add(" → [1.1]")
Ω(s).To(Equal("[0] → [1] → [1.1]"))
})
Convey("Test 1.2:", func() {
add(" → [1.2]")
Ω(s).To(Equal("[0] → [1] → [1.2]"))
})
})
// 👇change to FConvey to focus on this block and all children
// 👇change to SConvey to skip the block
// 👇change to SConveyAsTODO to mark as TODO
Convey("Test 2:", func() {
add(" → [2]")
Ω(s).To(Equal("[0] → [2]"))
Convey("Test 2.1:", func() {
add(" → [2.1]")
Ω(s).To(Equal("[0] → [2] → [2.1]"))
})
Convey("Test 2.2:", func() {
add(" → [2.2]")
Ω(s).To(Equal("[0] → [2] → [2.2]"))
})
})
SkipConveyAsTODO("failure message", func() {
// 👆 change SkipConvey to Convey to see failure messages
Convey(colorz.Cyan.Wrap("👉 this test will fail"), func() {
// Expected
// <string>: [0] → [2]
// to equal
// <string>: this test will fail
Ω(s).To(Equal("this test will fail"))
})
Convey(colorz.Cyan.Wrap("👉 this test has UNEXPECTED error"), func() {
// UNEXPECTED ERROR: Refusing to compare <nil> to <nil>.
// Be explicit and use BeNil() instead. This is to avoid mistakes where both sides of an assertion are erroneously uninitialized.
Ω(nil).To(Equal(nil))
})
Convey(colorz.Cyan.Wrap("👉 this test will panic"), func() {
examples.CallFunc(func() {
examples.WillPanic()
})
})
})
})
}