Configures Koin on project #11
Conversation
I know it. Dropped from 100% of coverage. |
c0ecfed
to
1b6715b
Everything is quite nice! The only thing that worries me is that the TestSocialApp is not just "overriding" what we want in the test but also bootstrapping a completely different global Koin instance. I think this can be improved for the test only re-configuring what it needs. |
app.initKoin(newValue) | ||
|
||
// Act | ||
val activity = Robolectric.setupActivity(MainActivity::class.java) |
victorolinasc
May 8, 2018
Collaborator
This seems more like an arrange as well... I know that in this case we would end up with an empty Act comment, but you are not actually doing nothing in the Activity so it should be explicit that there is no action for the assertions below.
This seems more like an arrange as well... I know that in this case we would end up with an empty Act comment, but you are not actually doing nothing in the Activity so it should be explicit that there is no action for the assertions below.
val activity = Robolectric.setupActivity(MainActivity::class.java) | ||
|
||
// Assert | ||
assertThat(activity).isNotNull() |
victorolinasc
May 8, 2018
Collaborator
I don't think there is much value in this assertion. If it is null it will fail on the line below with a very clear NPE so I'd just skip this assertion.
I don't think there is much value in this assertion. If it is null it will fail on the line below with a very clear NPE so I'd just skip this assertion.
import org.koin.android.ext.android.startKoin | ||
import org.koin.dsl.module.applicationContext | ||
|
||
class TestSocialApp : Application() { |
victorolinasc
May 8, 2018
Collaborator
There is one thing here which worries me a bit: your test application has nothing to do with your production application. If possible, I'd try to minimize this by extending SocialApp
class instead. This would make initializing Koin a bit more complicated though I think it pays off. IMHO it is really important to have the execution stack as close to the production as we can.
There is one thing here which worries me a bit: your test application has nothing to do with your production application. If possible, I'd try to minimize this by extending SocialApp
class instead. This would make initializing Koin a bit more complicated though I think it pays off. IMHO it is really important to have the execution stack as close to the production as we can.
@victorolinasc please review :) |
Nice! It reuses the application now. I will rest much more easily now hehehe Way to go! |
Adds a basic infrastructure to allow us to mock (if needed) or replace dependencies for tests. This will be useful when implementing real features for our app.