public void setupFailureHandler(Description description) { final String testClassName = description.getClassName(); final String testMethodName = description.getMethodName(); final Context context = InstrumentationRegistry.getTargetContext(); Espresso.setFailureHandler(new FailureHandler() { @Override public void handle(Throwable throwable, Matcher<View> matcher) { SpoonScreenshotAction.perform("espresso_assertion_failed", testClassName, testMethodName); new DefaultFailureHandler(context).handle(throwable, matcher); } }); }
@Override public Statement apply(final Statement base, final Description description) { Espresso.setFailureHandler(new FailureHandler() { @Override public void handle(Throwable error, Matcher<View> viewMatcher) { Spoon.screenshot(SpoonTestRule.this.getActivity(), error.getClass().getSimpleName(), description.getClassName(), description.getMethodName()); new DefaultFailureHandler(SpoonTestRule.this.getActivity()).handle(error, viewMatcher); } }); return super.apply(base, description); }
public EspScreenshotFailureHandler(Context targetContext) { delegate = new DefaultFailureHandler(targetContext); }
public BaseFailureHandler(BaseInstrumentTestCase fixture) { this.fixture = fixture; this.delegate = new DefaultFailureHandler(fixture.getInstrumentation().getTargetContext()); }
public CustomFailureHandle(Context targetContext) { delegate = new DefaultFailureHandler(targetContext); }