I have about 400 unit tests that I have written for my Android application. If I run the tests package by package, everything works fine and all my tests pass. However, if I try
I investigated this again and, as far as I can tell, this is purely an issue with the Android Eclipse plugin. An issue that seems to be fixed, but still can occur sometimes (possibly it's machine-dependent).
As you mention, the Eclipse plugin appears to run all the tests twice. What it's actually doing the first time is gathering the test suite and test names, so that it can show all the test names in that nice hierarchical JUnit UI.
However, "running" the tests like this seems to cause a problem. As part of Android SDK Tools v8, a "workaround" was added which places a 15ms delay between checking each test. This is done to prevent "Binder transaction failures ... for large test suites".
Indeed, I went back to my project that was having the "FAILED BINDER TRANSACTION" errors, and I could not reproduce it on the command line. We also tried in Eclipse and it couldn't be reproduced any more (even although I'm sure we had SDK Tools r8+ when we originally saw this).
However, I can still generally reproduce it in Eclipse. Try running your tests again from Eclipse with the latest Android tools, or try out this minimal GitHub repository I created and see if you can reproduce it:
https://github.com/orrc/android-large-test-failures#readme