I am writing my test specs in Ginkgo.
My tests have the following structure:
It("Setup X, Y, Z resources and check conditions" func() {
// setup resources.
// assert certain conditions using
//cleanup resources
})
My question is, how do I perform cleanup when assertion fails. If I use afterEach block for this purpose, then it executes same cleanup on all test specs, which shows with a bunch of failures to cleanup messages.
what's the recommended way to cleanup on failure with ginkgo.
You can keep this test in seperate context. Then afterEach will only apply to all the It under that context: