自动化测试 - android UI单元测试-Espresso的相关学习资料?
PHPz
PHPz 2017-04-17 15:40:09
0
2
269

题主现在能完成基本的相对复杂的espresso单元测试了,包括寻找各种复杂嵌套List的item,view的各种perform等,但是再深入一点的东西在网上完全找不到相关资料。gitHub上面google的官方espresso demo也看完了,也全部是一些简单的例子,根本不可能覆盖整个项目的测试。
题主这里想咨询各位,有没有完整深入讲解espresso的资料或者书籍。例如:如何验证数据(经过计算的数字)的正确性,而不是简单地对比字符串。又或者espresso根本就是只注重UI?验证数据正确性用espresso不适合?希望对espresso有一定研究的各位高手解答。

PHPz
PHPz

学习是最好的投资!

reply all(2)
洪涛

Some time ago, due to work needs, I studied some things about automated testing, including Espresso provided by Android, and the third-party cross-platform Appium. Both of these focus on UI testing, and functional or unit tests still need to be written with other tools.

I basically read through the official documents provided by Espresso, including UI Automator. Espresso can basically meet the needs of business process testing of a single APP (of course UI-oriented testing), and UI Automator (and Appium) has good support for cross-APP testing.

I am currently writing a series of articles on automated testing, which can be viewed on my homepage for reference~ There are indeed very few reference materials in this area, and I hope we can communicate more~

伊谢尔伦

Since no one has answered, I can only answer my progress myself.
There are still many in-depth functions that have not been explored, but as far as my question mentioned, verifying the accuracy of the data. Because I have not found an operation that can simulate a very important operation in human operations, which is "observation & recording". In other words, I don't know how to get the Text content in a TextView I found. If you know this step, you can record some data and compare it. The following is a solution I found that can getText().

String getText(final Matcher<View> matcher) {
    final String[] stringHolder = { null };
    onView(matcher).perform(new ViewAction() {
        @Override
        public Matcher<View> getConstraints() {
            return isAssignableFrom(TextView.class);
        }

        @Override
        public String getDescription() {
            return "getting text from a TextView";
        }

        @Override
        public void perform(UiController uiController, View view) {
            TextView tv = (TextView)view; //Save, because of check in getConstraints()
            stringHolder[0] = tv.getText().toString();
        }
    });
    return stringHolder[0];
}

Code excerpted from: http://stackoverflow.com/questions/23381459/how-to-get-text-from-textview-using-espresso

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!