Proposal: add .Panic() alongside .Return(...) for interrupting a test
unkeep opened this issue · 1 comments
unkeep commented
It would be useful for testing expectations which do not return an error or the error does not interrupt a flow.
example code:
func foo(dep Dependency) {
dep.doSmth1(...)
dep.doSmth2(...)
}
example test:
It("should doSmth1", func(){
depMock.Expect(...).Panic()
Ω(func(){foo(depMock)}).Should(Panic())
})
Of course the same could be done by adding panic() to the end of Inspect func, but the proposed way is more natural and shorter
hexdigest commented
Hey, you can achieve the same using Set
:
It("should doSmth1", func(){
depMock.Set(func(...) {
panic("is good for you")
})
Ω(func(){foo(depMock)}).Should(Panic())
})
I don't think it deserves a special helper.