Automation Test

Ginkgo detected a panic while constructing the test tree

How to fix this

Donald Le
2 min readJun 7, 2022

--

/api-testing/gt-mvp/aaa/bbb/c_test.go:28
Ginkgo detected a panic while constructing the test tree.
You may be trying to make an assertion in the body of a container node
(i.e. Describe, Context, or When).

Please ensure all assertions are inside leaf nodes such as BeforeEach,
It, etc.

Here's the content of the panic that was caught:
Your Test Panicked
Expect(resp.StatusCode()).To(Equal(http.StatusOK))
/api-testing/gt-mvp/gtcommon/api/user.go:25
When you, or your assertion library, calls Ginkgo's Fail(),
Ginkgo panics to prevent subsequent assertions from running.

Normally Ginkgo rescues this panic so you shouldn't see it.

However, if you make an assertion in a goroutine, Ginkgo can't capture the
panic.
To circumvent this, you should call

defer GinkgoRecover()

at the top of the goroutine that caused this panic.

Alternatively, you may have made an assertion outside of a Ginkgo
leaf node (e.g. in a container node or some out-of-band function) - please
move your assertion to
an appropriate Ginkgo node (e.g. a BeforeSuite, BeforeEach, It, etc...).

Learn more at:…

--

--

Donald Le

A passionate automation engineer who strongly believes in “A man can do anything he wants if he puts in the work”.