Reputation: 7476
I'm building an android library for Android developers. I want start unit testing my library and I'm looking for a good framework. I saw many articles about Robolectric, but the problem is my library doesn't contain a lot of UI/Activities/Services or other Android elements.
I want to use Robolectric for regular java unit testing, and in not many cases where I need Robolectric for UI/Services test I'll use the Robolectic features.
My questions are: 1. Can I use Robolectric for pure java unit testing? And if I can, I will be happy to get a good tutorial for this. 2. Does Robolectric is the best framework for my needs?
Upvotes: 1
Views: 211
Reputation: 5151
The short answer is yes.
You can setup your project with robolectric & Junit4. Then, when you have tests that do not touch any Android-specific bits, you can just run them as normal JUnit tests. When you need Robolectric, you use the Robolectric test runner. The runner you use is what makes the difference.
You run them all as JUnit tests anyway, so your entire library tests out with one run.
Upvotes: 2