-
Notifications
You must be signed in to change notification settings - Fork 0
/
main_test.go
45 lines (43 loc) · 1.43 KB
/
main_test.go
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
package main
import (
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)
var _ = Describe("Using helper functions in tests", func() {
Context("Ginkgo", func() {
When("assertions are used in the helper function", func() {
It("prints USELESS line number in colorized text and summaries", func() {
ginkgoHelper1("some-value")
})
})
When("assertions are used in the test body", func() {
It("prints USEFUL line number in colorized text and summaries", func() {
err := ginkgoHelper2("some-value")
if err != nil {
Fail("Something is failing")
}
})
})
})
Context("Gomega", func() {
When("assertions are used in the helper function", func() {
It("prints USELESS line number but USEFUL automatic text in colorized text and summaries", func() {
gomegaHelper1("some-value")
})
})
When("assertions are used in the test body", func() {
It("prints USEFUL line number but MISSES automatic text in colorized text and summaries", func() {
err := gomegaHelper2("some-value")
Expect(err).NotTo(HaveOccurred())
})
})
When("the helper function returns an GomegaMatcher", func() {
It("prints USEFUL line number and USEFUL automatic text in colorized text and summaries. Getting the best of both worlds", func() {
val := "some-value"
Expect(val).To(gomegaHelper3())
// Using better functions names makes the code easy to read
// Expect(val).To(beASupportedValue())
})
})
})
})