of code that invokes a unit of work in the system and then checks a single assumption about the behavior of that unit of work. - The art of unit testing What are we going to test in Android? Business Logic View validation Behavior sábado, 30 de noviembre de 13
de-fangs the Android SDK jar so you can test- drive the development of your Android app ‣Rewrite the Android SDK classes to be able to load in the JVM ‣Can use resources, themes, etc ‣Use Shadow Objects a.k.a Proxies: 1. Intercept of loading Android SUT 2. Rewrite the body 3. Bind “shadow object” to the new Android object ‣ Is possible to build your own shadow objects sábado, 30 de noviembre de 13
instrument -w - e size small com.android.foo/ android.test.InstrumentationTestRunner Running all medium tests: adb shell am instrument - w -e size medium com.android.foo/ android.test.InstrumentationTestRunner Running all large tests: adb shell am instrument -w - e size large com.android.foo/ android.test.InstrumentationTestRunner Source: http://googletesting.blogspot.com.es/2010/12/test-sizes.html sábado, 30 de noviembre de 13
onView(withId(R.id.currency_input_field)).perform(typeText("10")); onView(withId(R.id.convert_cash_button)).perform(click()); onView(withId(R.id.amount_converted)).check(matches(withText("7.4"))); assertTrue(true); } EXAMPLES onData(allOf(is(instanceOf(String.class)), is("Americano"))) .perform(click()); sábado, 30 de noviembre de 13