It depends on what parts you want to test. If you need the android
test framework classes for testing activities and services in a valid
android context then i am not sure if you can make junit 4 work with
it.

However, if you extract your app logic into android independant
classes then you can test them by having junit 4 in the classpath
before the android jar.

I use this for testing with junit 4 and jmock 2 and mockito. What i
had to do is provide some dummy implementation of Bundle and Intent.
Otherwise you will see the Stub! Exception thrown by the android
classes. (You have to write dummy implementations for all android
classes that you cannot get around as dependencies. Your dummy
implementations have to be placed in the classpath before the android
jar, too, of course.)

Easy to setup in intellij. A bit more work to get right on the command
line with ant.

Cheers
Daniel


On 19 Aug., 02:39, Eric <[email protected]> wrote:
> It appears that Android supports JUnit 3 out of the box.  However, I
> have some pre-existing JUnit 4 unit tests that I'd like to try on
> Android.  I've tried adding the JUnit 4 jar to eclipse and compiling/
> running the tests by pointing a standard JUnit run against them, but
> nothing seems to happen.  There's no evidence in the eclipse console
> or the Android emulator that any tests have been run.
>
> Can anyone with knowledge about this subject comment?  Is it even
> possible to run JUnit 4 tests under Android, and if so, is there a
> step-by-step explanation as to how to achieve this (preferably under
> Jetbrains IDEA IDE, and/or Eclipse).
>
> Thank You,
> Eric

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to