【问题标题】:Espresso testing with ExpandableListView使用 ExpandableListView 进行 Espresso 测试
【发布时间】:2016-09-22 07:30:46
【问题描述】:

我使用 espresso 作为我的 UI 自动化测试。我想为ExpandableListView 创建一个matcher,因为它有时会离开屏幕,并且在绑定了adapter 的视图上调用onView(withText("something")) 并不是一个好习惯。有人可以告诉我如何为ExpandableListView 创建matcher 吗?

【问题讨论】:

标签: android expandablelistview android-espresso android-testing expandablelistadapter


【解决方案1】:

我不知道这个是否有用,但是:

 public static Matcher<Object> withListItemCheck(final <Type> check_value) {
    checkNotNull(check_value);
    return new BoundedMatcher<Object, <List_Item_class>>(<List_Item_class>.class) {
        private String m_message = "";

        @Override
        public void describeTo(Description d) {
            d.appendText(m_message);
        }

        @Override
        public boolean matchesSafely(<List_Item_class> listItem) {
            m_message = "Expected " + listItem+ " and got ";
            if (listItem== null) {
                m_message +=  "empty";
                return false;
            }
            return <assertion to check `check_value` is corresponding to `listItem` or not>;
        }
    };
}

取自:accessing children in custom expandablelist using android espresso

希望对你有帮助

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多