e2e: improve description of framework callbacks

When Ginkgo shows a BeforeEach/AfterEach/DeferCleanup, then it can only show
the source code where the callback was registered because there is no
description parameter. This can be improved by passing a custom CodeLocation.

Because a description like "set up framework" might not be enough, the source
code is still shown, too.
This commit is contained in:
Patrick Ohly
2022-09-13 14:27:32 +02:00
parent 0f37b31206
commit 84990d53cf
3 changed files with 48 additions and 15 deletions

View File

@@ -155,7 +155,7 @@ func NewFramework(baseName string, options Options, client clientset.Interface)
Timeouts: NewTimeoutContextWithDefaults(),
}
ginkgo.BeforeEach(f.BeforeEach)
ginkgo.BeforeEach(f.BeforeEach, AnnotatedLocation("set up framework"))
return f
}
@@ -167,10 +167,10 @@ func (f *Framework) BeforeEach() {
// remains valid as long as possible.
//
// In addition, AfterEach will not be called if a test never gets here.
ginkgo.DeferCleanup(f.AfterEach)
ginkgo.DeferCleanup(f.AfterEach, AnnotatedLocation("tear down framework"))
// Registered later and thus runs before deleting namespaces.
ginkgo.DeferCleanup(f.dumpNamespaceInfo)
ginkgo.DeferCleanup(f.dumpNamespaceInfo, AnnotatedLocation("dump namespaces"))
ginkgo.By("Creating a kubernetes client")
config, err := LoadConfig()