-
-
Notifications
You must be signed in to change notification settings - Fork 650
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This function returns a wrapper around GinkgoT() which satisfies the `testing.TB` interface. - Update fail tests with tests for GinkgoT() and GinkgoTB(). - Fix a bug where GinkgoT().Fail() was not reporting the correct line on error.
- Loading branch information
Showing
7 changed files
with
195 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
integration/_fixtures/fail_fixture/fail_fixture_ginkgo_t_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package fail_fixture_test | ||
|
||
import ( | ||
. "github.com/onsi/ginkgo/v2" | ||
) | ||
|
||
var _ = Describe("GinkgoT", func() { | ||
It("synchronous failures with GinkgoT().Fail", func() { | ||
GinkgoT().Fail() | ||
println("NEVER SEE THIS") | ||
}) | ||
|
||
DescribeTable("DescribeTable", | ||
func() { | ||
GinkgoT().Fail() | ||
}, | ||
Entry("a TableEntry constructed by Entry"), | ||
) | ||
|
||
It("tracks line numbers correctly when GinkgoT().Helper() is called", func() { | ||
ginkgoTHelper() | ||
}) | ||
|
||
It("tracks the actual line number when no helper is used", func() { | ||
ginkgoTNoHelper() | ||
}) | ||
}) | ||
|
||
var ginkgoTNoHelper = func() { | ||
GinkgoT().Fail() | ||
} | ||
var ginkgoTHelper = func() { | ||
GinkgoT().Helper() | ||
GinkgoT().Fail() | ||
} |
36 changes: 36 additions & 0 deletions
36
integration/_fixtures/fail_fixture/fail_fixture_ginkgo_tb_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package fail_fixture_test | ||
|
||
import ( | ||
. "github.com/onsi/ginkgo/v2" | ||
) | ||
|
||
var _ = Describe("GinkgoTB", func() { | ||
It("synchronous failures with GinkgoTB().Fail", func() { | ||
GinkgoTB().Fail() | ||
println("NEVER SEE THIS") | ||
}) | ||
|
||
DescribeTable("DescribeTable", | ||
func() { | ||
GinkgoTB().Fail() | ||
}, | ||
Entry("a TableEntry constructed by Entry"), | ||
) | ||
|
||
It("tracks line numbers correctly when GinkgoTB().Helper() is called", func() { | ||
ginkgoTBHelper() | ||
}) | ||
|
||
It("tracks the actual line number when no GinkgoTB helper is used", func() { | ||
ginkgoTBNoHelper() | ||
}) | ||
}) | ||
|
||
var ginkgoTBNoHelper = func() { | ||
GinkgoTB().Fail() | ||
} | ||
var ginkgoTBHelper = func() { | ||
t := GinkgoTB() | ||
t.Helper() | ||
t.Fail() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters