Reputation: 9508
Android newbie here, using ADT
I have a few number crunching classes in my app that are "pure" Java - they don't depend on anything in the Android SDK. Ideally, I'd like to test them without firing off the (somewhat slow) emulator. Is that possible and if yes, how?
From what I gather so far, Dalvik compilation and resulting classes are different than the ones expected from "normal" JVMs and that rules out regular JUnit tests (what happens if you try). Using the JUnit in the Android SDK starts the emulator. Here's where my Google fu fails me for everyone is preoccupied testing UI.
Upvotes: 0
Views: 152
Reputation: 1006859
Is that possible and if yes, how?
Option #1: Follow Mike B's comment and move that code to a separate JAR project with its own unit tests.
Option #2: Use Robolectric to run dedicated tests for these classes on the JVM. While Robolectric is mostly designed to test Android-y code on the JVM, I see no reason why you could not use it for your scenario as well.
Upvotes: 1