我正在用Ginkgo编写我的测试规范。
我的测试具有以下结构:
It("Setup X, Y, Z resources and check conditions" func() {
// setup resources.
// assert certain conditions using
//cleanup resources
}) 我的问题是,当断言失败时,我如何执行清理。如果我将afterEach块用于此目的,那么它将对所有测试规范执行相同的清理,其中显示了一系列清理消息的失败。
用ginkgo清理失败的推荐方法是什么?
发布于 2019-07-11 11:56:07
您可以将此测试保存在单独的context中。则afterEach将仅应用于该上下文下的所有It:
Context("Setup X, Y, Z resources and check conditions", func() {
BeforeEach(func() {
// do ...
})
AfterEach(func() {
// do clean up
})
It("should pass the condition", func() {
// do ...
})
})https://stackoverflow.com/questions/56979836
复制相似问题