https://kotlinlang.org logo
Title
d

dave08

05/27/2021, 3:47 PM
Is withData
TestType.Test
@sam? (In the listener this is the check:
private fun TestCase.isApplicable() = (mode == KoinLifecycleMode.Root && description.isRootTest()) ||
   (mode == KoinLifecycleMode.Test && type == TestType.Test)
s

sam

05/27/2021, 3:47 PM
No its test type container
d

dave08

05/27/2021, 3:48 PM
Oh... so I guess I'll have to add a Container mode to that listener for it to work... thanks!
d

dave08

05/27/2021, 3:56 PM
Is there some kind of
TestType.Leaf
?
s

sam

05/27/2021, 3:56 PM
TestType.Test
I just said leaf in there to remind myself to call the parameter leaf
withData(1,2,3, leaf = true) { }
I think that makes more sense than testType = TestType.Test to people who don't know the innards of kotest
d

dave08

05/27/2021, 3:58 PM
🙃 It seems like multiple containers tries starting up Koin multiple times, whereas I'd like the most inner container (the withData) BEFORE the `it`s inside it...
s

sam

05/27/2021, 3:59 PM
yeah that's quite specific
if you want to use koin, I would use withData at the root level
d

dave08

05/27/2021, 3:59 PM
I tried using:
private fun TestCase.isApplicable() = (mode == KoinLifecycleMode.Root && description.isRootTest())
        || (mode == KoinLifecycleMode.Test && type == TestType.Test)
        || (mode == KoinLifecycleMode.Container && type == TestType.Container)
in the KoinListener but it doesn't work...
Even with a describeSpec?
s

sam

05/27/2021, 4:00 PM
class Foo : DescribeSpec({
  withData(1,2,3) { }
})
that would work with koin
basically you can't have nested tests with it
d

dave08

05/27/2021, 4:01 PM
Maybe there should be a DataTestSpec? It seems like there's just too many conditions to work with them... Koin, IsolationMode problems...
s

sam

05/27/2021, 4:03 PM
It's more a problem with nested tests in general
Once you start nesting you have to decide what you're going to treat as a single test unit
I might rename TestType.TEST to LEAF in 5.0
I just copied the junit naming and it's not very clear
d

dave08

05/27/2021, 7:29 PM
Then what would you do about isolation mode instance per leaf?