When I declare a dependency in a junit `@BeforeEac...
# koin
l
When I declare a dependency in a junit
@BeforeEach
method, why does it fail to create the
MyService
in
Copy code
@BeforeEach
fun setup(): Unit = declare { MyService() }
whereas with the following it is ok ?
Copy code
@BeforeEach
fun setup(): Unit {
  declare { MyService() }
}
1
Got it, this is a junit behavior. It expects
@BeforeEach
to return
Unit
, but
fun setup(): Unit
doesn't make it return
Unit
. However the following works:
Copy code
@BeforeEach
    fun setup() = declare { MyService() }.let { }
a
or just
fun setup() { declare { MyService() } }
?
l
yes 👍
👍 1