{"id":775,"date":"2023-02-26T21:47:20","date_gmt":"2023-02-26T13:47:20","guid":{"rendered":"https:\/\/www.appblog.cn\/?p=775"},"modified":"2023-04-29T16:56:48","modified_gmt":"2023-04-29T08:56:48","slug":"android-test-android-ui-automation-test","status":"publish","type":"post","link":"https:\/\/www.appblog.cn\/index.php\/2023\/02\/26\/android-test-android-ui-automation-test\/","title":{"rendered":"Android\u6d4b\u8bd5\uff086\uff09\uff1aAndroid UI\u81ea\u52a8\u5316\u6d4b\u8bd5"},"content":{"rendered":"<p>\u539f\u6587\uff1a<a target=\"_blank\" rel=\"noopener\" href=\"https:\/\/developer.android.com\/training\/testing\/ui-testing\/index.html\">https:\/\/developer.android.com\/training\/testing\/ui-testing\/index.html<\/a><\/p>\n<p>\u7528\u6237\u754c\u9762\uff08UI\uff09\u6d4b\u8bd5\u7684\u4e00\u79cd\u65b9\u6cd5\u662f\u7b80\u5355\u5730\u8ba9\u6d4b\u8bd5\u4eba\u5458\u5728\u76ee\u6807\u5e94\u7528\u7a0b\u5e8f\u4e0a\u6267\u884c\u4e00\u7ec4\u7528\u6237\u64cd\u4f5c\uff0c\u5e76\u9a8c\u8bc1\u5176\u884c\u4e3a\u662f\u5426\u6b63\u786e\u3002\u4f46\u662f\uff0c\u8fd9\u79cd\u624b\u52a8\u65b9\u6cd5\u53ef\u80fd\u8017\u65f6\u3001\u4e4f\u5473\u3001\u4e14\u5bb9\u6613\u51fa\u9519\u3002\u66f4\u6709\u6548\u7684\u65b9\u6cd5\u662f\u7f16\u5199\u60a8\u7684UI\u6d4b\u8bd5\uff0c\u4ee5\u4fbf\u7528\u6237\u64cd\u4f5c\u4ee5\u81ea\u52a8\u65b9\u5f0f\u6267\u884c\u3002\u81ea\u52a8\u5316\u65b9\u6cd5\u80fd\u591f\u4ee5\u53ef\u91cd\u590d\u7684\u65b9\u5f0f\u5feb\u901f\u53ef\u9760\u5730\u8fd0\u884c\u6d4b\u8bd5\u3002<\/p>\n<p><!-- more --><\/p>\n<p>\u8981\u4f7f\u7528Android Studio\u81ea\u52a8\u6267\u884cUI\u6d4b\u8bd5\uff0c\u8bf7\u5728\u5355\u72ec\u7684Android\u6d4b\u8bd5\u6587\u4ef6\u5939src\/androidTest\/java\u4e2d\u5b9e\u73b0\u6d4b\u8bd5\u4ee3\u7801\u3002\u9488\u5bf9Gradle\u7684Android\u63d2\u4ef6\u5c06\u6839\u636e\u6d4b\u8bd5\u4ee3\u7801\u6784\u5efa\u6d4b\u8bd5\u5e94\u7528\u7a0b\u5e8f\uff0c\u7136\u540e\u5c06\u6d4b\u8bd5\u5e94\u7528\u7a0b\u5e8f\u52a0\u8f7d\u5230\u4e0e\u76ee\u6807\u5e94\u7528\u7a0b\u5e8f\u76f8\u540c\u7684\u8bbe\u5907\u4e0a\u3002\u5728\u6d4b\u8bd5\u4ee3\u7801\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528UI\u6d4b\u8bd5\u6846\u67b6\u6765\u6a21\u62df\u76ee\u6807\u5e94\u7528\u7a0b\u5e8f\u4e0a\u7684\u7528\u6237\u4ea4\u4e92\uff0c\u4ee5\u6267\u884c\u8986\u76d6\u7279\u5b9a\u4f7f\u7528\u573a\u666f\u7684\u6d4b\u8bd5\u4efb\u52a1\u3002<\/p>\n<p>\u4e3a\u4e86\u6d4b\u8bd5Android\u5e94\u7528\u7a0b\u5e8f\uff0c\u901a\u5e38\u4f1a\u521b\u5efa\u8fd9\u4e9b\u7c7b\u578b\u7684UI\u81ea\u52a8\u5316\u6d4b\u8bd5\uff1a<\/p>\n<ul>\n<li><strong>\u5355\u4e2a\u5e94\u7528\u7a0b\u5e8f\u7684UI\u6d4b\u8bd5<\/strong><\/li>\n<\/ul>\n<p>\u8fd9\u79cd\u7c7b\u578b\u7684\u6d4b\u8bd5\u9a8c\u8bc1\u5f53\u7528\u6237\u6267\u884c\u7279\u5b9a\u64cd\u4f5c\u6216\u5728\u5176\u6d3b\u52a8\u4e2d\u8f93\u5165\u7279\u5b9a\u5185\u5bb9\u65f6\uff0c\u76ee\u6807\u9a8c\u8bc1\u5e94\u7528\u7a0b\u5e8f\u7684\u884c\u4e3a\u662f\u5426\u7b26\u5408\u9884\u671f\u3002\u5b83\u5141\u8bb8\u4f60\u68c0\u67e5\u76ee\u6807\u5e94\u7528\u7a0b\u5e8f\u662f\u5426\u8fd4\u56de\u6b63\u786e\u7684UI\u8f93\u51fa\uff0c\u4ee5\u54cd\u5e94\u5e94\u7528\u7a0b\u5e8f\u6d3b\u52a8\u4e2d\u7684\u7528\u6237\u4ea4\u4e92\u3002\u50cfEspresso\u8fd9\u6837\u7684UI\u6d4b\u8bd5\u6846\u67b6\u5141\u8bb8\u4ee5\u7f16\u7a0b\u65b9\u5f0f\u6a21\u62df\u7528\u6237\u64cd\u4f5c\u5e76\u6d4b\u8bd5\u590d\u6742\u7684\u5e94\u7528\u5185\u7528\u6237\u4ea4\u4e92\u3002<\/p>\n<ul>\n<li><strong>\u8de8\u8d8a\u591a\u4e2a\u5e94\u7528\u7a0b\u5e8f\u7684UI\u6d4b\u8bd5<\/strong><\/li>\n<\/ul>\n<p>\u8fd9\u79cd\u7c7b\u578b\u7684\u6d4b\u8bd5\u9a8c\u8bc1\u4e0d\u540c\u7528\u6237\u5e94\u7528\u7a0b\u5e8f\u4e4b\u95f4\u6216\u7528\u6237\u5e94\u7528\u7a0b\u5e8f\u4e0e\u7cfb\u7edf\u5e94\u7528\u7a0b\u5e8f\u4e4b\u95f4\u4ea4\u4e92\u7684\u6b63\u786e\u884c\u4e3a\u3002\u4f8b\u5982\uff0c\u53ef\u80fd\u60f3\u8981\u6d4b\u8bd5\u4f60\u7684\u76f8\u673a\u5e94\u7528\u7a0b\u5e8f\u4e0e\u7b2c\u4e09\u65b9\u793e\u4ea4\u5a92\u4f53\u5e94\u7528\u7a0b\u5e8f\u6216\u9ed8\u8ba4\u7684Android\u7167\u7247\u5e94\u7528\u7a0b\u5e8f\u6b63\u786e\u5171\u4eab\u56fe\u50cf\u3002\u652f\u6301\u8de8\u5e94\u7528\u7a0b\u5e8f\u4ea4\u4e92\u7684UI\u6d4b\u8bd5\u6846\u67b6\uff08\u5982UI Automator\uff09\u5141\u8bb8\u4e3a\u8fd9\u4e9b\u65b9\u6848\u521b\u5efa\u6d4b\u8bd5\u3002<\/p>\n<p>\u672c\u6587\u5c06\u63cf\u8ff0<strong>\u5982\u4f55\u4f7f\u7528Android\u6d4b\u8bd5\u652f\u6301\u5e93\u4e2d\u7684\u5de5\u5177\u548cAPI\u6765\u6784\u5efa\u8fd9\u4e9b\u7c7b\u578b\u7684\u81ea\u52a8\u5316\u6d4b\u8bd5<\/strong>\uff1a<\/p>\n<ul>\n<li><a target=\"_blank\" rel=\"noopener\" href=\"https:\/\/developer.android.com\/training\/testing\/ui-testing\/espresso-testing.html\" title=\"Testing UI for a Single App\">Testing UI for a Single App<\/a>\uff08\u5355\u4e2a\u5e94\u7528\u7a0b\u5e8f\u7684UI\u6d4b\u8bd5\uff09<\/li>\n<\/ul>\n<p>\u4e86\u89e3\u5982\u4f55\u4f7f\u7528Espresso\u6d4b\u8bd5\u6846\u67b6\u5728\u5355\u4e2a\u5e94\u7528\u7a0b\u5e8f\u4e2d\u6d4b\u8bd5UI\u3002<\/p>\n<ul>\n<li><a target=\"_blank\" rel=\"noopener\" href=\"https:\/\/developer.android.com\/training\/testing\/ui-testing\/uiautomator-testing.html\" title=\"Testing UI for Multiple Apps\">Testing UI for Multiple Apps<\/a>\uff08\u591a\u4e2a\u5e94\u7528\u7a0b\u5e8f\u7684UI\u6d4b\u8bd5\uff09<\/li>\n<\/ul>\n<p>\u4e86\u89e3\u5982\u4f55\u4f7f\u7528UI Automator\u6d4b\u8bd5\u6846\u67b6\u5728\u591a\u4e2a\u5e94\u7528\u7a0b\u5e8f\u4e2d\u6d4b\u8bd5UI\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u539f\u6587\uff1ahttps:\/\/developer.android.com\/training\/testing\/ui-te [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[222],"tags":[],"class_list":["post-775","post","type-post","status-publish","format-standard","hentry","category-android-test"],"_links":{"self":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/775","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/comments?post=775"}],"version-history":[{"count":0,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/775\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/media?parent=775"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/categories?post=775"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/tags?post=775"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}