From dbaf18fd0af2b798961b08ee9c0a3266d3abadd6 Mon Sep 17 00:00:00 2001 From: Onsi Fakhouri Date: Wed, 17 Jan 2024 13:03:06 -0700 Subject: [PATCH] Document areas where GinkgoT() behaves differently from testing.T adresses #1331 --- docs/index.md | 5 +++++ ginkgo_t_dsl.go | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/docs/index.md b/docs/index.md index 7f30a36e8..15ef9187d 100644 --- a/docs/index.md +++ b/docs/index.md @@ -5480,6 +5480,11 @@ When using Gomock you may want to run `ginkgo` with the `-trace` flag to print o Similarly for third party libraries which accept a `testing.TB` interface, use the `GinkgoTB()` function. This function returns a struct wrapper around `GinkgoT()` which satisfies the `testing.TB`interface. If you need to use any Ginkgo-specific methods you can access the wrapped `GinkgoT()` instance using `GinkgoTBWrapper.GinkgoT`. +In general, `GinkgoT()` attempts to mimic the behavior of `testing.T` with the exception of the following: + +- `Error`/`Errorf`: failures in Ginkgo always immediately stop execution and there is no mechanism to log a failure without aborting the test. As such `Error`/`Errorf` are equivalent to `Fatal`/`Fatalf`. +- `Parallel()` is a no-op as Ginkgo's multi-process parallelism model is substantially different from go test's in-process model. + ### IDE Support Ginkgo works best from the command-line, and [`ginkgo watch`](#watching-for-changes) makes it easy to rerun tests on the command line whenever changes are detected. diff --git a/ginkgo_t_dsl.go b/ginkgo_t_dsl.go index 639541a16..02c6739e5 100644 --- a/ginkgo_t_dsl.go +++ b/ginkgo_t_dsl.go @@ -15,6 +15,11 @@ GinkgoT() is analogous to *testing.T and implements the majority of *testing.T's GinkgoT() takes an optional offset argument that can be used to get the correct line number associated with the failure - though you do not need to use this if you call GinkgoHelper() or GinkgoT().Helper() appropriately +GinkgoT() attempts to mimic the behavior of `testing.T` with the exception of the following: + +- Error/Errorf: failures in Ginkgo always immediately stop execution and there is no mechanism to log a failure without aborting the test. As such Error/Errorf are equivalent to Fatal/Fatalf. +- Parallel() is a no-op as Ginkgo's multi-process parallelism model is substantially different from go test's in-process model. + You can learn more here: https://onsi.github.io/ginkgo/#using-third-party-libraries */ func GinkgoT(optionalOffset ...int) FullGinkgoTInterface {