30

What are good ways to learn Android testing? I'm interested in learning Android testing, I don't actually do TDD but write the tests and code together.

I read all the information at http://developer.android.com/tools/testing/index.html and the 'Android Application Testing Guide' book and understand the basic concepts but there is almost no information or examples out there that I can find.

the book and examples are very basic and showing how to test a pretty simple activity with 2 EditText boxes,

I need to test more complicated stuff such as IntentService, AsyncTask, ResultReceiver, etc.. I'm interested in building my apps in a TDD or almost TDD way.

is there any way I can learn those things (books, blogs, examples, ...) or Android testing is something very uncommon ?

Gal Ben-Haim
  • 17,433
  • 22
  • 78
  • 131

2 Answers2

11

Question is a bit old and quite few things changed from the time it was asked.

Forget old Robotium, RoboElectric etc..Those were all just temporal and workaround solutions. Android Studio comes now with 1st party testing solution. JUnit Tests doesn't need to run anymore on device but on development host (aka your Mac/Pc machine) JVM. So read a lot, whatever you find (newer books, blog posts, google announcements) and experiment.

Use JUnit with Mockito, Espresso and UiAutomator. There will be more and more explanations on Android Developers pages about those tools. Happy testing ;)

Ewoks
  • 12,285
  • 8
  • 58
  • 67
3

You can write JUnit tests for Unit testing. If you want to test the UI, I'd recommend using a framework like Robotium they have lots of examples on their website, and it makes automated UI testing very easy.

I'm not sure about more advanced techniques, but a tool like Robotium coupled with some good unit tests will give you a good start.

DiscDev
  • 38,652
  • 20
  • 117
  • 133