works... but what's the difference? It sounds from the docs that
beforeEach
should be called before each test case with the type
Test
,
should
isn't a
Test
?
w
wasyl
12/06/2020, 4:27 PM
Perhaps you need to set a different
isolationMode
to have the behavior you expect?
d
dave08
12/06/2020, 4:29 PM
Maybe... but I put all the code inside the
should
, so that shouldn't really affect this... I'm just having trouble understanding the difference between the various lifecycle stages...
w
wasyl
12/06/2020, 4:35 PM
Me too, and I don’t use
beforeTest
and
afterTest
much really, so I mostly wanted to mention isolation mode in case you didn’t know that the default is somewhat confusing for JUnit users (as each spec is by default only instantiated once? I think)
Anyway we use listeners sparingly and since we’re using isolationMode#perLeaf, we can just rely on before/afterSpec for mostly junit-like behavior
d
dave08
12/06/2020, 4:41 PM
It seems like
Copy code
IsolationMode.SingleInstance
is the default..., thanks for the remark! I still need listeners for testcontainers though, and it's really puzzling how when a test is run by itself, it works, whereas in the whole suite, that same test fails...
w
wasyl
12/06/2020, 4:52 PM
Setting isolation mode to
perLeaf
should make the tests mostly independent, unless you’re sharing some statics. Or the listeners aren’t ran as you expect, but I’m not that familiar with them. Perhaps if you post a sample spec with simple listeners with prints and when you’d expect them to run but they don’t, someone will point you towards a solution 🙂
d
dave08
12/07/2020, 1:41 PM
Thanks! I finally managed to sort things out, your little pointer got rid of a problem that was hiding a problem in the actual test code... I guess I'll be using
perLeaf
until I manage to sort out the repercussions of the other modes...