Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Screenshot Testing for Android

Nikos Linakis
September 24, 2019

Screenshot Testing for Android

Screenshot Testing is a fast, simple, and fun way to develop UI while keeping your sanity and avoid visual regression bugs. In this talk Nikos and Christoforos will explain what is Screenshot Testing and how it protects and speeds up UI development. They’ll point out some common gotchas while paving the road to the “perfect pull-request”.

Nikos Linakis

September 24, 2019
Tweet

Other Decks in Programming

Transcript

  1. TESTING • Unit tests for business logic • UI tests

    for business or presentation logic • Robolectric for asserting view state • Espresso for interactions, layout
  2. WHY DO THIS? SCREENSHOT TESTING • They assert more properties

    than a unit test normally does • A fast way to see how our view looks while developing • Immediately detect UI breaking changes and avoid regression bugs
  3. + KARUMI/SHOT GRADLE PLUGIN SCREENSHOT-TESTS-FOR-ANDROID • Developed and used by

    Facebook • Html report (visual diff of failed tests) • CI friendly
  4. FIRST TEST import org.junit.Test class MyFirstTest { @Test @Throws(Throwable::class) fun

    testRendering() { val targetContext = getInstrumentation().targetContext val inflater = LayoutInflater.from(targetContext) val view = inflater.inflate(R.layout.market_hours_view, null, false) } }
  5. FIRST TEST import org.junit.Test class MyFirstTest { @Test @Throws(Throwable::class) fun

    testRendering() { val targetContext = getInstrumentation().targetContext val inflater = LayoutInflater.from(targetContext) val view = inflater.inflate(R.layout.market_hours_view, null, false) ViewHelpers.setupView(view).setExactWidthDp(300).layout() } }
  6. FIRST TEST import org.junit.Test class MyFirstTest { @Test @Throws(Throwable::class) fun

    testRendering() { val targetContext = getInstrumentation().targetContext val inflater = LayoutInflater.from(targetContext) val view = inflater.inflate(R.layout.market_hours_view, null, false) ViewHelpers.setupView(view).setExactWidthDp(300).layout() } }
  7. FIRST TEST import org.junit.Test class MyFirstTest { @Test @Throws(Throwable::class) fun

    testRendering() { val targetContext = getInstrumentation().targetContext val inflater = LayoutInflater.from(targetContext) val view = inflater.inflate(R.layout.market_hours_view, null, false) ViewHelpers.setupView(view).setExactWidthDp(300).layout() } }
  8. FIRST TEST import org.junit.Test class MyFirstTest { @Test @Throws(Throwable::class) fun

    testRendering() { val targetContext = getInstrumentation().targetContext val inflater = LayoutInflater.from(targetContext) val view = inflater.inflate(R.layout.market_hours_view, null, false) ViewHelpers.setupView(view).setExactWidthDp(300).layout() Screenshot.snap(view).record() } }