Skip to content

Instantly share code, notes, and snippets.

View bharatdodeja's full-sized avatar

Bharat Dodeja bharatdodeja

View GitHub Profile
@bharatdodeja
bharatdodeja / Robot Pattern.md
Last active December 17, 2023 12:21
Android UI testing using Espresso and Robot pattern

Android UI Testing using Espresso, Rotton Pattern and Kotlin DSL

Espresso allow UI tests to have stable interactions with your app, but without discipline these tests can become hard to manage and require frequent updating. Robot pattern allows you to create stable, readable, and maintainable tests with the aid of Kotlin’s language features.

Test Excecution

Let's say there is a login screen and user needs to login access dashboard by entering email and password and clicking on the login button. This is what we want the test to validate. But there’s also the how. Really, what we are looking for is the what.

Traditional Testing (Problem)

A way that you might write the test is something like this:

@bharatdodeja
bharatdodeja / FailureScreenshotRule.kt
Last active December 9, 2018 07:35
Android instrumentation testing using Espresso and Robot pattern
package com.bharatdodeja.robotpattern.utils
import org.junit.rules.TestWatcher
import org.junit.runner.Description
/**
* Created by bharat.dodeja@gmail.com
*/
class FailureScreenshotRule : TestWatcher() {