is there an alternative way to support spring cons...
# kotlintest
t
is there an alternative way to support spring constructor injection than https://github.com/kotlintest/kotlintest/blob/master/doc/extensions.md#constructor-injection ? The problem I am facing is that I have a class that works with
org.springframework.context.ApplicationEventPublisher
and I cannot unit test it. What I mean is, if I write a test like
Copy code
class SomeTest(
  private val applicationEventPublisher: ApplicationEventPublisher = mockk(relaxed = true),
  private val myClass: MyClass(applicationEventPublisher)) : StringSpec() {...}
applicationEventPublisher
visible to the test is not the mocked one but the one instantiated from
ProjectConfig
. A workaround is to have
Copy code
class SomeTest : StringSpec() {
  private val applicationEventPublisher: ApplicationEventPublisher = mockk(relaxed = true),
  private val myClass: MyClass(applicationEventPublisher)
...
}
so actually not a big deal
also, what is a bit ugly with a global
ProjectConfig
is that every test will start a small spring context, making every test not requiring spring slower than they should be