Showing posts with label android testing. Show all posts
Showing posts with label android testing. Show all posts

Monday, November 12, 2018

Login pase Testing Using Expresso Android studio.



Source

1. build.gradle(module.app)




2. MainActivity.java




3. xml layout of the mainActivity class activity_main.xml




4. welcome Activity and this layout




5. Testing MainActivity which is Login form .




GitHub Link



Espresso Resources

Friday, November 9, 2018

Espresso dependencies

/*Espresso testing */
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test:rules:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'

Full code of dependency:CODE



Toast message check




Code END




Saturday, November 3, 2018

how to create custome Matcher in Espresso android studio

Create a class name  ErrorMatcher in androidTest folder.


public class ErrorMatcher {



@NonNull

public static Matcher withError(final Matcher stringMatcher) {

return new BoundedMatcher(TextView.class) {


@Override

public void describeTo(final Description description) {
description.appendText("error text: ");
stringMatcher.describeTo(description);
}


@Override

public boolean matchesSafely(final TextView textView) {
return stringMatcher.matches(textView.getError().toString());
}
};
}
}


# Maching logic is to match the subtext of the textview with only the error message.

#describeTo method only for debug.

# you can use this as your custom matcher in the test case as shown in below.

===================


@Test 

public void testLoginMandatory()
{
    onView(withId(R.id.email_sign_in_button)).perform(click());
    onView(ErrorMatcher.withError(Matchers.
            containsString("The field is required"))).check(matches(isDisplayed()));

}



Source