Yeah I should note somewhere exactly where this te...
# kotlin-inject
e
Yeah I should note somewhere exactly where this test pattern came about. The goal was to be able to pass in test fakes, while having a set of defaults. Ideally you wouldn't even need the
TestFakes
class and do:
Copy code
@Component
@ApplicationScope
abstract class TestApplicationComponent(
    @get:Provides val episodesDao: EpisodesDao = FakeEpisodesDao(),
    @get:Provides val songsDao: SongsDao = FakeSongsDao(),
)
but the problem is that due to a limitation with kapt/ksp the generated
create()
method can't forward default args, so you are stuck with providing all of them. So yeah
@Component
was meant to take a parent component to obtain additional bindings from, but I ended up not requiring the annotation on it because it can be useful at times to abstract out what's passed as a parent and the actual impl, for example in a multimodule setup.
Copy code
interface MyParentComponent {
  @get:Provides val foo: Foo
}
@Component
abstract class MyParentComponentImpl : MyParentComponent { ... }
I discovered that this flexibility works for this use-case as well, as if you pass in a concrete object you get your default args back!