Android Development Tutorial-Android unit testing

Aug 2, 2010

Android Development Tutorial-Android unit testing

Mon, 07/19/2010 – 06:51 | by gabor

SDK Version:

M3

For unit testing you can use the built in JUnit framework just like in “standard” java applications.

A unit test is to test some low-level part – usually a single class – of a project, working individually.

The only trick is to extend AndroidTestCase in your test case instead of TestCase some Android specific methods, like getContext() which is often required by android functions.

Lets see a very simple example using eclipse:

- Create a new project to test, create a new class in it, with a simple method that , like this:

  1. public class ClassToTest{
  2. public int add(int arg1,int arg2){
  3. return arg1+arg2;
  4. }
  5. }

- Create a new test project: File/new/Other…/Android/Android Test Project
new Android Test Project

Add the previously created project as the test target, the other fields can be left as they are auto filled.

This Android Tutorial has been taken from Hello Android Tutorial

Many students are currently enrolled in the Android Tutorial from EDUmobile.

Join now and start you career as an Android developer

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • Blogplay

Share with others

No Responses so far | Have Your Say!

Leave a Feedback

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

rss
Карта