To start testing with Espresso, first you need to add the espresso dependency in your app level build.gradle.

testCompile 'junit:junit:4.12'
androidTestCompile ''
androidTestCompile ''

Requirement: Check if a button is disabled or not after taking some input from Edittext and clicking the button once.

Suppose your Edittext Id is: @+id/username and Button Id is: @+id/login_button . Your Simple Espresso Test Class would look like:

public class Your_Class_Name_EspressoTest {
	public ActivityTestRule<Your_Class_Name> mActivityRule =
            new ActivityTestRule<>(Your_Class_Name);

	public void ensureButtonDisableAfterOneClick() {
                .perform(ViewActions.typeText(My Name),closeSoftKeyboard());

So, first you define the rule and then write the test case for that class. Here we are first taking the input from Edittext and then performing click operation on Button. And then finally checking if the Button is disable now or not. The convention of putting this test class is under androidTest package at the same place where your relevant class is residing in the main package.