Hello 🙂 Does Kaocha run tests in parallel?
I've been debugging some behaviour that seems to result from a fixture setting a global var to X before the test, then resetting it to Y after. And it seems like for some random amount of tests on reach run using this fixture, they see Y.
Kaocha runs the tests in a random order. This probably means that one or more of your tests have side effects that affect the tests being run after it. You can reproduce the same order using a given random seed.
Ah, the fixture is used :once , that is once for a namespace. If kaocha interleaves tests from different namespaces when running them, this can explain the fixture side-affecting the global var at an unfortunate time.
So, switching to :each should also fix it.
It does! Thank you @magnars, this was very enlightening 🙂
it wouldn't interleave different namespaces. Randomization happens on each level of nesting, so if you have multiple test suites, they run in a random order. For each test suite the namespaces run in a random order, and for each namespace, tests within them run in a random order. We have a big old PR that adds actual parallelism... it's kind of experimental. Feedback from people actually using it would be welcome.
What you're saying means my issue isn't yet explained, then, @plexus ... Since I'm seeing the error when instrumenting :once per namespace. But instrumenting :each fixes the issue.
Will investigate further the coming week. From what you're saying, it sounds unrelated to Kaocha.