Unit testing • Robolectric + Mockito • No emulator = fast • Focus on ViewModel and Model. Activity and Fragment are not target. • Easy to inject mock objects by Dagger 2 • Run by git push on Circle CI
@Test fun doAction_doesSomething(){ /* Given */ val mock = mock { on { getText() } doReturn "text" } val classUnderTest = ClassUnderTest(mock) /* When */ classUnderTest.doAction() /* Then */ verify(mock).doSomething(any()) }
jacoco-android-gradle-plugin • Add gradle tasks to run unit test and code coverage • Need to exclude classes generated by kapt • Data binding, ORM, Parcelable, etc • No badge now • Codecov, Coveralls
ktlint-gradle • Coding style checker and formatter for Kotlin • Default style is official style from kotlinlang.org • Not same as Android Studio default setting • Override: ktlint —apply-to-idea • Run style check on Circle CI
UI testing • Espresso + UI automator • Use Espresso basically • Use UI automator to OS/other app UI (ex. permission dialog) • Don’t run on CI due to long exec time • Run before release to confirm important flows don’t degrade • ex. Sign up flow
Mock in UI testing • MockWebServer of Retrofit • Unlike Mockito, JSON parse can be tested • Share MockWebServer object between Application class and test classes • Change API response at every test case
Firebase Test Lab • Still experimental • Run UI testing on OS x device matrix • In parallel • Video recording in testing • 5 or 10 tests/day in free plan • Run before release manually?
Crashlytics • Share the latest apk to team • master branch = debug build • Development endpoint • Debug screen with debot • Deploy at every git push (10~ times / day) • release/1.2.3 branch = beta build • Production endpoint • Deploy at code freeze
Google Play • gradle-play-publisher • Gradle wrapper of Google Play Developer API • Need to set up Google API console • Can publish as alpha, beta and staging rollout • Triggered by GitHub Release (git tag) • However CircleCI 2.0 doesn't support tag…
Like • Can start by free event if private repo • Many users • We can search YAML file on GitHub • Kind support • ex. Memory limit of my project has been increased before