wood burning stoves 2.0*
The moose likes Android and the fly likes UNit Testing and TDD for Android Developent Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Mobile » Android
Bookmark "UNit Testing and TDD for Android Developent" Watch "UNit Testing and TDD for Android Developent" New topic
Author

UNit Testing and TDD for Android Developent

Sahil Reddy
Ranch Hand

Joined: Jan 24, 2011
Posts: 145
Hello Pals,

I want to Unit test while developing for Android. Is there any Good Book or Resource to get started ???

Regards
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5772
    
    7

This prior discussion might help:
http://www.coderanch.com/t/547027/Android/Mobile/Android-testing-should-testing


JBoss In Action
Richard O'Shay
Greenhorn

Joined: Oct 11, 2008
Posts: 9
Unit testing is straightforward despite the mountain of information on it. There is a lot of incorrect information on unit testing, too, such as a method being a unit. Have you ever come across a method outside of a class in Java? In Java the Unit is the class, so a formal unit test must mock out each external dependency (your other classes). If you were to unit test methods you would have to mock all the other class methods! That would be costly and misguided. I suggest Mockito for mocking and TestNG for running your tests. You mock external classes, you test all the public methods of the class-under-test. If there are protected/private methods that are not exercised by that, what are they doing there?

Now, lets back up a bit. You must also perform integration tests to ensure your classes work together. A good boundary for this is the tiers of your application. At a minimum, you should not be making network or database calls as part of your integration tests. Nobody will lose any sleep if you loosely refer to these as "unit tests" but in fact they are integration tests. I would start with these "integration" tests if you are not used to TDD in general, then ease in to true unit tests. You will find it becomes easy, natural, and profitable to implement true unit tests. It can be a hard sell, especially to those who haven't actually done it, or don't really understand it.


We don't know if the climate change whosey-whatsit is man made or just a part of the end of days.
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5772
    
    7

And another prior discussion:
http://www.coderanch.com/t/532731/Android/Mobile/Unit-Testing-classes-aren-Activity
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: UNit Testing and TDD for Android Developent
 
Similar Threads
How can I test a android application which is based on event notification in Juni?
Unit Testing classes that aren't Activity/Service etc
Is there any Unit testing framework for Andriod Code ?
WA #1.....word association
WA #2 ..... word association