Office Hours — Today, December 8

Yesterday, December 7

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!
how can I help you today>
er, today?
Ivano
sorry for the delay
but the boss was speaking with me
Good <getMarkTime> you used CountDownLatch to test Retrofit 1 in your nice book
With Mockito
Mark M.
yes
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
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
I am sure that there are other java.util.concurrent approaches that would work as well
Ivano
OK
so basically Mockito have to be used when I am going to test a method that has a dependency
giving to that object a default behaviour
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?
PowerMock is good to test private methods
Mark M.
AFAIK that is possible, but I have not used Mockito with instrumentation tests
9:20 AM
Ivano
yep is tricky to use instrumentation and junit togheter
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
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
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
OK thanks
10:00 AM
Mark M.
that is a wrap for today's chat
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
have a pleasant day!
Ivano
you too
Ivano
has left the room
Mark M.
turned off guest access

Yesterday, December 7

 

Office Hours

People in this transcript

  • Ivano
  • Mark Murphy