• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java FailureHandler类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中android.support.test.espresso.FailureHandler的典型用法代码示例。如果您正苦于以下问题:Java FailureHandler类的具体用法?Java FailureHandler怎么用?Java FailureHandler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



FailureHandler类属于android.support.test.espresso包,在下文中一共展示了FailureHandler类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: testForCoverage

import android.support.test.espresso.FailureHandler; //导入依赖的package包/类
@Test
public void testForCoverage() {
    espScreenshotFailureHandler.delegate = new FailureHandler() {
        @Override
        public void handle(Throwable error, Matcher<View> viewMatcher) {
            // avoid that exception is thrown by default failure handler
        }
    };

    espScreenshotFailureHandler.handle(new TestException(), isRoot());
    File screenshot = new File(InstrumentationRegistry.getTargetContext().getFilesDir(), "test-screenshots/Failed-EspScreenshotFailureHandlerTest.testForCoverage.png");
    assertThat(screenshot.exists(), is(true));

    //noinspection ResultOfMethodCallIgnored
    screenshot.delete();
}
 
开发者ID:nenick,项目名称:espresso-macchiato,代码行数:17,代码来源:EspScreenshotFailureHandlerTest.java


示例2: testScreenshotFailure

import android.support.test.espresso.FailureHandler; //导入依赖的package包/类
@Test
public void testScreenshotFailure() {
    espScreenshotFailureHandler.delegate = new FailureHandler() {
        @Override
        public void handle(Throwable error, Matcher<View> viewMatcher) {
            // avoid that exception is thrown by default failure handler
            wasDelegateCalled = true;
        }
    };

    InstrumentationRegistry.getInstrumentation().runOnMainSync(new Runnable() {
        @Override
        public void run() {
            espScreenshotFailureHandler.handle(new TestException(), isRoot());
        }
    });

    assertTrue(wasDelegateCalled);
}
 
开发者ID:nenick,项目名称:espresso-macchiato,代码行数:20,代码来源:EspScreenshotFailureHandlerTest.java


示例3: setupFailureHandler

import android.support.test.espresso.FailureHandler; //导入依赖的package包/类
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);
        }
    });
}
 
开发者ID:sregg,项目名称:spotify-tv,代码行数:13,代码来源:FailureScreenshotRule.java


示例4: apply

import android.support.test.espresso.FailureHandler; //导入依赖的package包/类
@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);
}
 
开发者ID:byoutline,项目名称:SecretSauce,代码行数:12,代码来源:SpoonTestRule.java


示例5: onFailure

import android.support.test.espresso.FailureHandler; //导入依赖的package包/类
/** 
 * Replaces NoMatchingViewException with MySpecialException (to be caught in the test)
 */
@Override
public void onFailure(FailureHandler delegate, Throwable error, Matcher<View> viewMatcher) {
    try {
        delegate.handle(error, viewMatcher);
    } catch (NoMatchingViewException e) {
        throw new MySpecialException(e);
    }
}
 
开发者ID:mindbody,项目名称:Ironhide,代码行数:12,代码来源:CustomFailureHandlerTest.java


示例6: ignoringFailures

import android.support.test.espresso.FailureHandler; //导入依赖的package包/类
/**
 * <b>Modifies the given ViewInteraction</b> to have a no-op FailureHandler. Use this, e.g.,
 * to perform an action on a View if it's visible and not complain if it isn't.
 *
 * @return the modified ViewInteraction
 */
static ViewInteraction ignoringFailures(@NonNull ViewInteraction interaction) {
    return interaction.withFailureHandler(new FailureHandler() {
        @Override
        public void handle(Throwable error, Matcher<View> viewMatcher) {
        }
    });
}
 
开发者ID:1fish2,项目名称:BBQTimer,代码行数:14,代码来源:CustomMatchers.java


示例7: onFailure

import android.support.test.espresso.FailureHandler; //导入依赖的package包/类
/** @see android.support.test.espresso.Espresso#setFailureHandler(android.support.test.espresso.FailureHandler) */
protected void onFailure(FailureHandler delegate, Throwable error, Matcher<View> viewMatcher) {
    delegate.handle(error, viewMatcher);
}
 
开发者ID:mindbody,项目名称:Ironhide,代码行数:5,代码来源:BaseInstrumentTestCase.java



注:本文中的android.support.test.espresso.FailureHandler类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Position类代码示例发布时间:2022-05-22
下一篇:
Java ADM类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap