Created
July 21, 2016 05:56
-
-
Save engincancan/7e6b0b056dd77f9c562f460075e77e13 to your computer and use it in GitHub Desktop.
EspressoCustomFailureHandler.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
//Instrumentation instrumentation = InstrumentationRegistry.getInstrumentation(); | |
//Espresso.setFailureHandler(new CustomFailureHandler(instrumentation)); | |
public class CustomFailureHandler implements FailureHandler { | |
private final FailureHandler delegate; | |
public CustomFailureHandler(@NonNull Instrumentation instrumentation) { | |
delegate = new DefaultFailureHandler(instrumentation.getTargetContext()); | |
} | |
@Override | |
public void handle(final Throwable error, final Matcher<View> viewMatcher) { | |
// Log anything you want here | |
// Then delegate the error handling to the default handler which will throw an exception | |
delegate.handle(error, viewMatcher); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment