Show a toast in android UI test

Normally if I try to show a toast in a non-ui android test , it ends up throwing an error :

can't create handler inside thread that has not called looper.prepare()

Xdroid-Toaster is sub-project of Xdroid Library. Simplify your life using Toaster :

  1. Context variable is not required.
  2. RunOnUiThread() is not required.

How :

Dependency

dependencies {
    compile 'com.shamanland:xdroid-toaster:0.0.10'
}

Static import

import static xdroid.toaster.Toaster.toast;
import static xdroid.toaster.Toaster.toastLong;

Simple usage

// text from resource
toast(R.string.simplest_toast);

// hard-coded string
toast("Simplest hard-coded toast");

The details are Here.

你可能感兴趣的:(Show a toast in android UI test)