{"id":568,"date":"2013-05-25T16:50:46","date_gmt":"2013-05-25T08:50:46","guid":{"rendered":"http:\/\/www.yeetrack.com\/?p=568"},"modified":"2013-09-27T22:36:39","modified_gmt":"2013-09-27T14:36:39","slug":"robotium%e5%88%9d%e6%8e%a2%e7%a7%98","status":"publish","type":"post","link":"https:\/\/www.yeetrack.com\/?p=568","title":{"rendered":"Robotium\u521d\u63a2\u79d8"},"content":{"rendered":"<h4>Getting started<\/h4>\n<p>\u5982\u679c\u60f3\u77e5\u9053robotium\u662f\u5982\u4f55\u8fd0\u884c\u3001\u4ec0\u4e48\u6837\u5b50\u7684\uff0c\u5c31\u770b\u4e0b\u9762\u7684\u6b65\u9aa4\u3002\u5982\u679c\u60f3\u81ea\u5df1\u65b0\u5efa\u4e00\u4e2arobotium\u6d4b\u8bd5\u5de5\u7a0b\uff0c\u70b9\u51fb<a href=\"http:\/\/code.google.com\/p\/robotium\/wiki\/RobotiumTutorials\" target=\"_blank\">\u6b64\u5904<\/a><br \/>\n\u8981\u4f7f\u7528Robotium\uff0c\u9700\u8981\u628aRobotium.jar\u653e\u5728\u6d4b\u8bd5\u5de5\u7a0b\u7684build path\u4e2d\u3002Eclipse\u4e2d\u53f3\u952e--&gt;build path\uff0cIDEA\u4e2d\u53f3\u952e--&gt;open moduler\u3002<!--more--><\/p>\n<h4>\u6837\u4f8b\u5de5\u7a0b<\/h4>\n<p>\u4e0b\u8f7d<a href=\"http:\/\/robotium.googlecode.com\/files\/ExampleTestProject_v4.1.zip\" target=\"_blank\">ExampleTestProject_v4.1.zip<\/a>\uff0c\u91cc\u9762\u5305\u542b\u4e00\u4e2a\u7b80\u5355\u7684android\u5c0f\u5de5\u7a0b\u548c\u7b80\u5355\u7684\u6d4b\u8bd5\u5de5\u7a0b\u3002<br \/>\nEclipse\u4e2d\uff0c\u76f4\u63a5\u5bfc\u5165\u5373\u53ef\u3002\u5bfc\u5165\u540e\uff0c\u5c31\u53ef\u4ee5\u5728\u771f\u673a\u6216\u8005\u6a21\u62df\u5668\u4e2d\u8fd0\u884c\uff0c\u8fd0\u884c\u65b9\u6cd5\uff1a\u53f3\u51fb\u5de5\u7a0b\u540d\uff0c\u9009\u62e9Run As--&gt;Run As Android JUnit Test\u3002\u4e0b\u9762\u5c31\u662f\u4e00\u4e2atest case\uff08\u4e00\u4e2acase\u53ef\u4ee5\u8de8\u8d8a\u591a\u4e2aactivity\uff0c\u4e0b\u9762\u4e2d\u7684EditorActivity\u662f\u7b2c\u4e00\u4e2aactivity\uff09\u3002<\/p>\n<pre><code>public class EditorTest extends\n            ActivityInstrumentationTestCase2&lt;EditorActivity&gt; \n{\n\n    private Solo solo;\n\n    public EditorTest() {\n            super(EditorActivity.class);\n    }\n\n    public void setUp() throws Exception {\n        solo = new Solo(getInstrumentation(), getActivity());\n    }\n\n    public void testPreferenceIsSaved() throws Exception \n    {\n            solo.sendKey(Solo.MENU);\n            solo.clickOnText(\"More\");\n            solo.clickOnText(\"Preferences\");\n            solo.clickOnText(\"Edit File Extensions\");\n            Assert.assertTrue(solo.searchText(\"rtf\"));\n\n            solo.clickOnText(\"txt\");\n            solo.clearEditText(2);\n            solo.enterText(2, \"robotium\");\n            solo.clickOnButton(\"Save\");\n            solo.goBack();\n            solo.clickOnText(\"Edit File Extensions\");\n            Assert.assertTrue(solo.searchText(\"application\/robotium\"));\n\n    }\n\n    @Override\n    public void tearDown() throws Exception {\n        solo.finishOpenedActivities();\n    }\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Getting started \u5982\u679c\u60f3\u77e5\u9053robotium\u662f\u5982\u4f55\u8fd0\u884c\u3001\u4ec0\u4e48\u6837\u5b50\u7684\uff0c\u5c31\u770b\u4e0b\u9762\u7684\u6b65\u9aa4\u3002\u5982\u679c\u60f3\u81ea\u5df1\u65b0\u5efa\u4e00\u4e2arobotium\u6d4b\u8bd5\u5de5\u7a0b\uff0c\u70b9\u51fb\u6b64\u5904 \u8981\u4f7f\u7528Robotium\uff0c\u9700\u8981\u628aRobotium.&#46;&#46;&#46;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"pgc_sgb_lightbox_settings":"","footnotes":""},"categories":[33],"tags":[7,16,42,41],"class_list":["post-568","post","type-post","status-publish","format-standard","hentry","category-coding","tag-7","tag-16","tag-42","tag-41"],"views":2825,"_links":{"self":[{"href":"https:\/\/www.yeetrack.com\/index.php?rest_route=\/wp\/v2\/posts\/568","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.yeetrack.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.yeetrack.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.yeetrack.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.yeetrack.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=568"}],"version-history":[{"count":1,"href":"https:\/\/www.yeetrack.com\/index.php?rest_route=\/wp\/v2\/posts\/568\/revisions"}],"predecessor-version":[{"id":569,"href":"https:\/\/www.yeetrack.com\/index.php?rest_route=\/wp\/v2\/posts\/568\/revisions\/569"}],"wp:attachment":[{"href":"https:\/\/www.yeetrack.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=568"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.yeetrack.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=568"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.yeetrack.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=568"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}