How to attach listener/override listeners inside l...
# kotlintest
a
How to attach listener/override listeners inside lambda based spec? https://github.com/kotlintest/kotlintest/blob/master/doc/reference.md#listeners usecase:
Copy code
class MyTest: StringSpec({
    val destroyable = Destroyable()

    // attach afterSpec listener
    // override fun afterSpec() = destroyable.destroy()
})
l
I don't believe it's possible to do that yet. We're working on lambda definitions to enable that kind of configuration. Although you can create it via lambda and still use the class:
Copy code
class MyTest : StringSpec({...}) {
listeners() = ...
}
👍 1
a
That can't reference out varaibles inside the lambda :(
l
Unfortunately, you're right
You'll have to go with the usual class version instead of the lambda version