https://kotlinlang.org logo
#mockk
Title
# mockk
j

Joan Colmenero

07/03/2019, 7:31 PM
I have a question if I have an
attachView
and
detachView
on my Presenter do I have to test these methods? Inside of the presenter I have the
loadData
and I have the unit tests for this
loadData
but then I have these methods and I don't know if I have to unit test those or not
r

rkeazor

07/04/2019, 8:58 PM
@Joan Colmenero a good rule of thumb is to test all non private methods
When your unit test, your unit testing units of code in isolation
j

Joan Colmenero

07/04/2019, 9:15 PM
But makes sense to test attachView and detachView? Because I do not know how to do it though
r

rkeazor

07/05/2019, 12:12 PM
as long as it doesn't have android code , and its public in your presenter, you should test it
j

Joan Colmenero

07/05/2019, 12:13 PM
How do I test attachView and detachView if I have no a getView? Then I have to create a getView method ?
r

rkeazor

07/06/2019, 12:47 PM
What do these methods actually do?
j

Joan Colmenero

07/06/2019, 5:47 PM
Assign a View to a view from parameter
r

rkeazor

07/06/2019, 8:10 PM
Than you pass a Mock of a view to the presenter
j

Joan Colmenero

07/06/2019, 8:11 PM
And the verify?
r

rkeazor

07/06/2019, 8:13 PM
Assert that the actual equals Mock
and detach you assert that the actual equals null
or whatever the method does
3 Views