Handwritten Text Recognition for manuscripts and early printed texts
Bring Back the Fun to Testing Android Apps with Robolectric
1. Bring Back the Fun to
Testing Android Apps
with Robolectric
Peter Friese - @peterfriese - http:/
/www.peterfriese.de
2. Bring Back the Fun to
Testing Android Apps
with Robolectric
Peter Friese - @peterfriese - http:/
/www.peterfriese.de
3. Testing Android Apps with Robolectric
What’s the problem?
Why is Robolectric a solution?
Demo
Peter Friese - @peterfriese - http:/
/www.peterfriese.de
7. Robolectric to the rescue!
Run tests in a regular JVM, not on Dalvik VM
•
Dexing
•
Packaging
•
Installation on device / emulator
Peter Friese - @peterfriese - http:/
/www.peterfriese.de
8. There is another problem…
protected void onCreate(Bundle savedInstanceState) {
throw new RuntimeException("Stub!");
}
Peter Friese - @peterfriese - http:/
/www.peterfriese.de
9. Robolectric Solution:
Shadow Objects
•
Intercept class loading
•
Rewrite method bodies (using ASM)
•
Intercept calls to Android classes, record state
in shadow classes
Peter Friese - @peterfriese - http:/
/www.peterfriese.de
10. FEST - Readability for Your Tests
Plain JUnit:
assertEquals(View.GONE, textView.getVisibility());
!
java.lang.AssertionError: expected:<8> but was:<0>
FEST:
assertThat(textView).isGone();
!
java.lang.AssertionError: Expected to be gone but was visible
Peter Friese - @peterfriese - http:/
/www.peterfriese.de