Yet one more thing: I just realized that `beforeTe...
# kotest
s
Yet one more thing: I just realized that
beforeTest()
in a
WordSpec
also gets called for the outer
WordSpecShouldContainerScope
. What can I use to just have something called for the contained actual tests, i.e. the
WordSpecTerminalScope
?
Looks like
beforeEach()
is the way to go...
s
beforeTest has always been "before every nested lambda". If you weren't seeing that before, sounds like a bug in 4.x with WordSpec
beforeEach is "before only leaf nodeS"
s
I believe the behavior was that like that before in Kotest 4, I just didn't realize until. as I was debugging other things...
As a side note, I believe the naming of the callback to be a bit unfortunate...
beforeEach()
sounds to me as if it would be called more often than
beforeTest()
, whereas the opposite is the case.
s
Yes the naming is shit
😄 1
beforeTest should be leaf's only but has existed since 1.0
As part of the docs work I am doing, I am going to add more pages on listeners as the docs don't do a good job of all the extensions atm
s
Yes, I agree calling
beforeTest()
on leaves only would be the more expected behavior.
s
beforeTest was meant to be deprecated in 5.0 due to this confusing behavior, because we added beforeAll as well which is the same thing.
But I decided not to deprecate it as I'm cautious about too many deprecations on something as fundamental as a test framework.
You could use
beforeAll
yourself, and forget
beforeTest
exists if you want.
s
Thanks, I'll probably do that.
What about a "soft deprecation" of
beforeTest()
?
s
I'm against deprecating anything that's used in 1000s of projects really. What I will do is just stop referencing beforeTest in docs and things, so over time it will fall out of use.