Aug 4 | 8:55 AM |
Mark M. | has entered the room |
Mark M. | turned on guest access |
MyWay | has entered the room |
Mark M. |
hello, MyWay!
|
Mark M. |
how can I help you today?
|
MyWay |
hello Mark!
|
MyWay |
From what I've understand there are two types of test: one running on jvm (e.g. junit) and one running on android framework (e.g. espresso), is this right? My first question is... what should I test? As it's me writing the test, probably I'd write only test which I already know will be passed (or I'd have already fixed the bug!). So what's the point of writing these kind of tests? Any tool to "random" stress test the app?
|
Aug 4 | 9:00 AM |
Mark M. |
"is this right?" -- mostly. JUnit4 is used for both unit testing (on the JVM) and instrumentation testing (with or without Espresso orUiAutomator)
|
Mark M. |
"what should I test?" -- your code! :-)
|
Mark M. |
"So what's the point of writing these kind of tests?" -- ideally, you aim for 100% code coverage
|
Mark M. |
that will ensure that you are testing all scenarios, not just the few that you know will work
|
Mark M. |
and, it will help you if you make changes to the code that break the app
|
MyWay |
so if there is a click on a button, I should test that the button is in the right state
|
Mark M. |
"Any tool to random stress test the app?" -- there is the Test Monkey
|
Mark M. |
I don't know that a button would have a state
|
Mark M. |
but, presumably, when the user clicks the button, something is supposed to happen
|
MyWay |
yes
|
Mark M. |
you test to confirm that the "something" actually happened
|
MyWay |
if I remember (maybe from your book), test monkey is a bit "limited"
|
Mark M. |
it is random GUI input
|
Mark M. |
it clicks on widgets and taps keys (e.g., BACK, HOME)
|
Mark M. |
your job is to survive the monkey
|
Mark M. |
i.e., not crash, regardless of what the monkey throws at you
|
MyWay |
eheh
|
MyWay |
yes, this seems good to me, because it could do something you didn't prevent
|
MyWay |
while when you write test, you're auto-fixing your code, in a sense
|
Mark M. |
well, yes and no
|
Mark M. |
that's where coverage analysis comes into play
|
Aug 4 | 9:05 AM |
Mark M. |
for any app of reasonable complexity, you will not be able to determine, by just looking at it, whether a test is guaranteed to run successfully
|
Aug 4 | 9:05 AM |
Mark M. |
you won't even necessarily know all the portions of the app that test touches
|
Mark M. |
so, you use coverage tools to try to test everything
|
Mark M. |
or as close to "everything" as you are in position to get
|
Mark M. |
this will include things like exception handlers and other failure scenarios
|
MyWay |
I see
|
MyWay |
about UI test, I'd like to add some: e.g. when the user swipe (or tap on a tab), I'd like to check that the viewpager switch to the right page, that the tab corrisponds and so on... I've seen many examples, but all very simple. Where can I find more info about testing, or more complex examples? This is what I'm trying to do: http://stackoverflow.com/questions/38708462/and...
|
Mark M. |
I have several chapters related to testing, but they would all qualify as "simple"
|
Mark M. |
it is possible that a dedicated book on Android testing, particularly Espresso, might get into details of the level that you seek
|
MyWay |
I think my problem is at "matching" the ui component, but I'm not sure
|
Mark M. |
you can run tests in the debugger
|
Mark M. |
beyond that, I can't really help you, as I have no idea what your code is that you are testing, other than the limited information in your SO question
|
MyWay |
I did a lot of tests, everything works, but when it come to that line (onView() or onData()) it hangs, or timeout, (or fails)
|
Aug 4 | 9:10 AM |
MyWay |
but if I write onView(withText("Test 1")), shouldn't it match everything which has Test 1 inside?
|
Mark M. |
onView() will probably choose the first one returned by the matcher
|
Mark M. |
I don't think the ViewInteraction created by onView() works over N views
|
MyWay |
in my case there is one, I want to match it, but it seems it does not get matched
|
MyWay |
I don't want the solution, but how should I proceed?
|
Mark M. |
perhaps there is something odd with TabLayout that does not work well with Espresso
|
MyWay |
ah
|
Mark M. |
while many widgets will be testable "out of the box", not all will
|
Mark M. |
that's why espresso-contrib has dedicated classes to help with RecyclerView, for example
|
Mark M. |
it's possible that TabLayout would need the same treatment
|
MyWay |
nice, I'll read more about Espresso in a specific book, as you said
|
ndrocchietto_ivano | has entered the room |
Mark M. |
you might also consider creating a sample app that reproduces your problem in testing TabLayout
|
Mark M. |
then, use that as the basis of a fresh SO question, focusing on how to test TabLayout with Espresso
|
Mark M. |
and, depending on what you get from that, perhaps file an issue on the issue tracker, with that sample project
|
Aug 4 | 9:15 AM |
Mark M. |
let me take a question from Ivano, and I will be back with you shortly
|
MyWay |
yes, thank you
|
Mark M. |
Ivano: your turn! do you have a question?
|
Mark M. |
Ivano: do you have a question?
|
Mark M. |
Ivano: if you have a question, chime in
|
Mark M. |
MyWay: back to you! do you have another question?
|
ndrocchietto_ivano |
I Mark, I truly apoligize, but I am at 3PM, and my boss asked me a question asa icome
|
ndrocchietto_ivano |
into the chat
|
ndrocchietto_ivano |
is undependent by me
|
Aug 4 | 9:20 AM |
ndrocchietto_ivano |
I have two things to communicate you
|
ndrocchietto_ivano |
first is a remark over pag 994 7.5 edition
|
ndrocchietto_ivano |
View paste
|
ndrocchietto_ivano |
but in the exhibit there is any debug{testCoverageEnabled = true}
|
Mark M. |
correct
|
Mark M. |
sure there is
|
ndrocchietto_ivano |
can be confusing, also in the git file did not see
|
Mark M. |
it is at the bottom of the code listing on page 994
|
ndrocchietto_ivano |
you are right
|
Mark M. |
it is also at the bottom of the file in the git repo
|
ndrocchietto_ivano |
OMG, maybe was 7.4 edition
|
ndrocchietto_ivano |
anyway I am clamorously wrong
|
Mark M. |
that's possible -- there may have been a bug that was fixed
|
ndrocchietto_ivano |
the second thing is over debugging...
|
ndrocchietto_ivano |
I am really curios to understand better the debug stacktrace, but cannot find nothing on the internet that explains what are the shadow$ klass, etc
|
ndrocchietto_ivano |
do you know where I can find more instruction to become a professional "breakpointer"?
|
Mark M. |
um, not really
|
ndrocchietto_ivano |
:(
|
Mark M. |
if by "shadow$ klass", you mean classes of the form MainActivity$1, those are anonymous inner classes
|
Aug 4 | 9:25 AM |
ndrocchietto_ivano |
??? made by the system reflection?
|
Mark M. |
e.g., button.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { // do something }}
|
Mark M. |
(though I missed the ); at the end of that code snippet)
|
ndrocchietto_ivano |
nobody is perfect
|
ndrocchietto_ivano |
mmh not sure we are speaking about the same thing
|
Mark M. |
if you can post a stack trace that shows what you are referring to, that might help
|
ndrocchietto_ivano |
sometimes for instance i found shadow$ klass = java.lang.String
|
ndrocchietto_ivano |
this is great, I will come back soon to you, thank you mark, for your meta suggestions, these questions would be downvoted in SO
|
Mark M. |
I do not recognize that, so I cannot tell you what it might refer to, sorry
|
Mark M. |
OK
|
ndrocchietto_ivano |
I will be more precise next week
|
ndrocchietto_ivano |
thanks
|
Mark M. |
let me take another question from MyWay, and I will be back with you shortly
|
Mark M. |
MyWay: back to you! do you have another question?
|
MyWay |
I'd like to add some new feature to my app, to do it I'd like to use a remote database to store some info. My question is: own server or already existent solution (e.g. google firebase)? My concerns are mainly about security. E.g. I want to save each user position (so database + rest api on the server, I think). I've also found this library, which seems interesting: https://github.com/jeffknupp/sandman2
|
MyWay |
there is no universal answer, but what do you think about it?
|
Mark M. |
personally, I am enough of a "control freak" that I would use my own server
|
Mark M. |
plenty of people use hosted BaaS (backend as a service) solutions like Firebase, though
|
Mark M. |
middle ground would be to host something like Parse's open source server yourself
|
MyWay |
https://github.com/ParsePlatform this one?
|
Aug 4 | 9:30 AM |
Mark M. |
I believe that is it
|
MyWay |
I'll read about it, thanks
|
MyWay |
a last thing... what do you think about the new google android developer certification? Have you done it already? :P
|
ndrocchietto_ivano |
(????)
|
Mark M. |
I have not been certified, as I have not had a need to
|
Mark M. |
I am somewhat surprised that Google elected to get into the developer certification space
|
MyWay |
yes
|
Mark M. |
until there is demand from employers for candidates to get certified, I would not worry about it too much
|
MyWay |
that's all for me, thank you very much as always, Mark
|
Mark M. |
you are very welcome
|
MyWay |
have a good day!
|
MyWay |
bye all
|
Mark M. |
Ivano: we are referring to https://developers.google.com/training/certific...
|
Mark M. |
Google announced it at the 2016 I|O conference
|
ndrocchietto_ivano |
saw is the nanodegree, I did it already the old version
|
Mark M. |
Ivano: back to you! do you have another question?
|
Aug 4 | 9:35 AM |
ndrocchietto_ivano |
well Mark do you know, I do not want really to ask too much every time, but you know the firebase/ server makes me curios over...
|
ndrocchietto_ivano |
the fact why android devs prefers LAMP, over the great Jersey Java framework
|
ndrocchietto_ivano |
the only explanation i can give to my self is that JAVA cost more to host
|
ndrocchietto_ivano |
do you have any remark on that?
|
Mark M. |
I cannot speak regarding Jersey, as I have not used it
|
ndrocchietto_ivano |
ok, looks cool to me.
|
Mark M. |
in general, different server stacks have had prominence over the years
|
Mark M. |
WAR-based Java Web app servers were the first big one, in the post-CGI era
|
Mark M. |
then, Ruby, mostly via Rails
|
Mark M. |
now, NodeJS
|
ndrocchietto_ivano |
learning, learning, learning
|
Mark M. |
in many cases, the people driving the choices for the server are not the Android developers, but the Web app developers
|
Mark M. |
since the same server gets used for both
|
ndrocchietto_ivano |
I see, good point
|
ndrocchietto_ivano |
OK thanks
|
Mark M. |
an Android developer might want Java on the server, for the same language on the client and the server, much as Web developers are interested in NodeJS, for the same language on the client and the server, but for a different client (Web vs. Android)
|
Aug 4 | 9:40 AM |
ndrocchietto_ivano |
makes sense. will see is a javascript vs java war
|
ndrocchietto_ivano |
for sure learning is always essential, i cannot dare to think i should learn even C, and C++ if want to do VR Android
|
Aug 4 | 9:50 AM |
MyWay | has left the room |
Aug 4 | 10:00 AM |
Mark M. |
that's a wrap for today's chat
|
Mark M. |
the transcript will be posted to https://commonsware.com/office-hours/ shortly
|
ndrocchietto_ivano |
have a nice US day, thanks
|
Mark M. |
the next chat is Tuesday at 9am US Eastern
|
Mark M. |
have a pleasant day/night/whatever! :-)
|
ndrocchietto_ivano | has left the room |
Mark M. | turned off guest access |