Thursday, August 18, 2011

LinuxCon 2011 North America: Introduction to Android Testing

It was terrific having such a great audience showing a big interest in the topic of my tutorial, asking questions and starting discussions that made the presentation more enjoyable. I really want to thank you all.

For those who missed it, here are the slides that should be available at the Linux Foundation web site any time soon too.


Adolfo said...
This comment has been removed by the author.
Adolfo said...

Thanks a lot for posting the slides Diego. I have a couple of questions regarding the code coverage section of your presentation.

* Is it still required to build Android from source code in order to enable EMMA, as you mention in your book?

* Did you use EclEmma to integrate the code coverage to Eclipse?

I did not attend LinuxCon, so the questions come from what I read in your post.

By the way, I've found your book very useful. The only thing I have had to figure out so far is how to put things together with Maven.

Diego Torres Milano said...

Hi Adolfo,
Thanks for your comments about the book. I'm glad to hear you found it useful.

1. No, it's not needed in many cases. See page 284: The undocumented Ant coverage target.

2. Good point, it's EclEmma, I should have include it in a slide, though the screenshots belong to EclEmma as you may have noticed.

If you search this blog for "maven" you'll find some posts.

Canvas said...

I met a problem, could you give some advice?
Target "coverage" does not exist in the project "TemperatureConverterActivityTes

Diego Torres Milano said...

In the latest release of Android SDK and tools things changed a little.
Use 'ant help' to see the options for your specific version but it would probably be:

[echo] test: Runs the tests. Project must be a test project and
[echo] must have been built. Typical usage would be:
[echo] ant [emma] debug installt test


$ ant emma debug installt test

would do the trick.

Dr. Brad Dennis said...

Hi Diego,

I'm following through your tutorial, but I have a question. What's the rationale behind writing tests for the mundane, static, gui properties such as alignments or default texts?

Dr. Brad Dennis said...
This comment has been removed by the author.
Diego Torres Milano said...

Sometimes you have to translate UI design documents into specs and testing for these mundane properties helps verifying them and also when the UI docs change you can go to a single place, change the values and then be sure the UI will satisfy the new requirements.

Dr. Brad Dennis said...

Very insightful, thank you Diego!

Marek said...

Hi Diego,

I see that you're fan of Android platform and unit testing. You might be interested in a new code coverage tool for Android - Atlassian Clover. Read the page.

Marek, Atlassian

Diego Torres Milano said...

Thanks for posting this info.
I have to confess that I'm also a fan of some of the Atlassian tools ;-)

Dr. Brad Dennis said...

Diego, how can I test XML Attributes that you can set but can't get?


EffantTerrible said...

Thanks a lot for posting about test !

I have some questions about the code coverage.

I built the build.xml using ant Build

and, in 154 page..... I typed "coverage"

but after that I saw error message which is that "BUILD FAILED Target "coverage" does not exist in the project "This is my project package name" " like that..

and I removed the "coverage" then, build success!

But, you know I need a files

I can not pull that file in my smart phone.



Diego Torres Milano said...

The problem is that a some point (I think Android Tools rev 14 or 15) the ant target names changes.

ant help

to see the targets available. Probably emma instead of coverage.

I would appreciate very much if you can post your comments to Google+ ( which are easier to follow up.

EffantTerrible said...

Thank you very much!

I solved that problem.

I typed "emma" instead of "coverage" then, I can see BUILD SUCCESS.

But, you know ... after that..

How can I get the files?

I used "adb" you stated. But, the message is that "that file does not exist"...

Do I have to use real-device?

If so,
1. step : compile the build.xml using ant
2. step : run in the real-device.
3. step : then, can I pull the data?

I executed that steps...but,, I also, could not find that file...

Could you explain more detail...

Thanks in advance..

Diego Torres Milano said...

You should use which is from my presentation at OSCON 2012 and include a lot of updates.

EffantTerrible said...
This comment has been removed by the author.
EffantTerrible said...
This comment has been removed by the author.
EffantTerrible said...


The problem is that "android update test-project -main ../ -path ./ "

First time..I typed that "android update project --path ./ --name AndroidTest --target android-10 --subprojects"

"--subprojects" is very important thing! Thank you! I checked your recommended ppt.

and next ! I typed that "android update test-project --main ../ --path ./

But! this is the problem!

I have to make test project!

So, I make test folder. and I typed like that " android create test-project --main ../"This part original android project location" --path ./
then, I typed that "ant emma debug install test"

Then, It works!

key point is that "Separate the project and test project".

Anyway, Thanks a lot !!

I really appreciate your help!
(you know, I already have your book)


Have a good day ! :)

Diego Torres Milano said...

Nice to hear you solved your problems.

ASN said...

I was looking a long time (5 days) for a way to get runtime code coverage for Android apps without writing a test case or Junit test. so I read the Android Application Testing Guide Ebook although useful but don't found any answer. I found a solution in your post
I want to calculate the runtime coverage code ( file). structure my project is: src>com.example>Instrumentation>EmmaInstrumentation src>com.example.calculator>Sources Java and gradle file doesn't add anyone. and give an error:

INSTRUMENTATION_STATUS: id=ActivityManagerService
INSTRUMENTATION_STATUS: Error=Unable to find instrumentation info for: ComponentInfo{com.example.calculator/com.example.instrumentation.EmmaInstrumentation}
android.util.AndroidException: INSTRUMENTATION_FAILED: com.example.calculator/com.example.instrumentation.EmmaInstrumentation
at Method)

Tanks alot