Mark M. |
has entered the room |
Mark M. |
turned on guest access |
Dec 8 |
9:10 AM |
Ivano |
has entered the room |
Mark M. |
hello, Ivano!
|
Mark M. |
how can I help you today>
|
Mark M. |
er, today?
|
Ivano |
sorry for the delay
|
Ivano |
but the boss was speaking with me
|
Ivano |
Good <getMarkTime> you used CountDownLatch to test Retrofit 1 in your nice book
|
Ivano |
With Mockito
|
Mark M. |
yes
|
Dec 8 |
9:15 AM |
Ivano |
I would like to know if the choice to use CountDownlatch was dictated by the fact of simulating delayed server responses
|
Ivano |
and if you ever heard of MockWebServer Library that according to someone in SO is quite used
|
Mark M. |
I have heard of MockWebServer; I have not used it and cannot comment on it
|
Ivano |
OK
|
Mark M. |
in terms of CountDownLatch, you need to do something to have your test thread wait for asynchronous results
|
Ivano |
I see
|
Mark M. |
I tend to use CountDownLatch for that
|
Mark M. |
I am sure that there are other java.util.concurrent approaches that would work as well
|
Ivano |
OK
|
Ivano |
so basically Mockito have to be used when I am going to test a method that has a dependency
|
Ivano |
giving to that object a default behaviour
|
Ivano |
so that I can junit test the behaviour
|
Mark M. |
there are other mock libraries that you could consider (e.g., PowerMock)
|
Ivano |
And I can combine Mockito with UI espresso tests in jacoco is that correct?
|
Ivano |
PowerMock is good to test private methods
|
Mark M. |
AFAIK that is possible, but I have not used Mockito with instrumentation tests
|
Dec 8 |
9:20 AM |
Ivano |
yep is tricky to use instrumentation and junit togheter
|
Ivano |
and always related to retrofit, as my code won the black belt of big ball of mud champions league... retrofit has onResponse where are attached some callbacks to the anonymous class with the results
|
Ivano |
it makes readable the code to move the anonymous class of retrofit in another class making the method static, or should I maintain the anonymous class?
|
Mark M. |
I cannot really answer that
|
Mark M. |
I do not know your code and cannot comment on whether something makes that code more readable
|
Ivano |
make sense is like reading a poem, there is a lot of subjectivity involved
|
Ivano |
OK thanks
|
Dec 8 |
10:00 AM |
Mark M. |
that is a wrap for today's chat
|
Mark M. |
the transcript will be available from https://commonsware.com/office-hours/ shortly
|
Ivano |
OK thanks
|
Mark M. |
the next chat is Tuesday, also at 9am US Eastern
|
Mark M. |
have a pleasant day!
|
Ivano |
you too
|
Ivano |
has left the room |
Mark M. |
turned off guest access |