While using Ginkgo for testing in Go, you might notice that when a suite is skipped inside a BeforeSuite, it still counts as a failure in the test summary.
For example:
ginkgo.BeforeSuite(func() {
if !CheckCondition() {
ginkgo.Skip("condition not available")
}
})
When the condition isn’t met, the suite shows this result:
FAIL! -- 0 Passed | 1 Failed | 0 Pending | 0 Skipped
You might expect the skipped suite to be marked as skipped, not failed.
This happens because Skip in BeforeSuite doesn’t apply to individual specs - it affects the entire suite initialization, which Ginkgo interprets as a setup failure, not a skipped spec.
To truly skip tests, consider using BeforeEach with conditional skipping or wrapping your specs with an if check so that the specs themselves are skipped gracefully rather than the suite setup.