kotest
kotest copied to clipboard
Support nested isolation mode per describe
Hello, I'm just getting started with Kotest and Kotlin in general.
I struggled with a test recently because I misunderstood how IsolationMode works. I thought I could do something like this
class SomeTest : DescribeSpec({
// default isolation mode: same for all the tests in the class
// we can make expensive setup here like booting a docker container
describe("Describe 1") {
isolationMode = IsolationMode.InstancePerLeaf
// some cheap setup that we can clear for each test *of the current scope, the current describe*
// and variables that should be independant per test for the current describe
it("Test 1") { ... }
it("Test 2") { ... }
}
}
Except that with the above example, there's no errors but the isolation mode per leaf is not applied. Which means I had my tests running but the variables defined in the describe where not independant. It was particularly confusing as I ran my tests one by one as I was writing them, and at the end when I try to run them all at once, it failed.
I think it'd be nice to be able to describe the isolation mode per describe instead of per class.
It wouldn't even be a breaking change as currently it only supports isolation mode to be set at the top, not in nested describe.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Up
It would be incredibly cool to change isolation mode per container to e.g. share container state across the inner tests
This would be neat but I fear the implementation would be very complex. It's already tricky enough to support the three isolation modes just at the top level.
Going to close because implementation of this is too complicated with edgecases.