• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Tim Cooke
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Jeanne Boyarsky
Saloon Keepers:
  • Stephan van Hulst
  • Carey Brown
  • Tim Holloway
  • Piet Souris
Bartenders:

UNit Testing and TDD for Android Developent

 
Ranch Hand
Posts: 145
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Pals,

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

Regards
 
author
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This prior discussion might help:
https://coderanch.com/t/547027/Android/Mobile/Android-testing-should-testing
 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Peter Johnson
author
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And another prior discussion:
https://coderanch.com/t/532731/Android/Mobile/Unit-Testing-classes-aren-Activity
 
The two armies met. But instead of battle, they decided to eat some pie and contemplate this tiny ad:
The Low Tech Laboratory Movie Kickstarter is LIVE NOW!
https://www.kickstarter.com/projects/paulwheaton/low-tech
reply
    Bookmark Topic Watch Topic
  • New Topic