"It's impossible to run Android Junit tests on the host machine, in a way 
that's reliable."

I completely agree that it is impossible to run Android JUnit tests on the 
host machine. And it shouldn't be.
My idea would be more inclined to have this tasks:

Gradle Test Task: For Pure Java (And I mean PURE, if you insert a single 
Android reference It should blow)
Gradle Android Test Task : The current task that  handles the launching of 
the test app in the emulator and run instrumentation tests (And maybe some 
JUnit tests that touches Android classes)
check task: the task that would launch this other tasks like the current 
check task does.

now multiply the above task for the different combination of flavors, 
buildtype and variants and whatnot.

Now with the above strategy you could implement your tests in several 
flexible ways:

1.- write your code with wrappers that isolate android classes (MVP) and 
use only the Pure Java Test task and Hope the wrappers are fine.
2.- write your code with wrappers that isolate android classes (MVP) and 
use the Pure Java Test task for you Presenters and the Android Test task 
for your Views (The one I prefer since you could develop with TDD speed and 
still test your Views every once in a while).
3.- write your code extending the Android classes and use the both test 
tasks depending if the class touches the android framework.
4.- write your code extending the Android classes and use Robolectric in 
conjunction with the Pure Java Test task to test your app (Not recommended 
by Jake nor me).
5.- write your code however you want and use only the gradle android test 
task to test both instrumentationTests and JUnit tests (the current way).

Currently only the 5th use case is possible and the 1st and 2nd are only 
possible if you split your app in a pure java module (with Java plugin) and 
an android module (either Android library or android app plugins).



"Even code that barely touches Android (e.g., Bundle, Intent) should be 
unit testable via mocks. "

This would be awesome too, but one step at a time...

-- 
You received this message because you are subscribed to the Google Groups 
"adt-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to