{"id":5044,"date":"2015-10-29T18:50:10","date_gmt":"2015-10-29T09:50:10","guid":{"rendered":"https:\/\/appkitbox.com\/en\/?page_id=5044"},"modified":"2015-10-29T18:50:10","modified_gmt":"2015-10-29T09:50:10","slug":"automation08","status":"publish","type":"page","link":"https:\/\/appkitbox.com\/en\/support\/automation\/automation08\/","title":{"rendered":"How to use Remote TestKit with NativeDriver"},"content":{"rendered":"<h2>How to use Remote TestKit with NativeDriver<\/h2>\n<p>You can also use the test automation tool NativeDriver via Remote TestKit.<br \/>\nNativeDriver is a testing framework specifically optimized for Android native applications. By using this framework in conjunction with Remote TestKit, you can carry out automated testing of native applications on a wide range of devices.<br \/>\n*In order to use this function, you need to set up ADB on your computer.<br \/>\nUnless otherwise specified, command-line tool refers to Command Prompt on Windows and Terminal on Mac.<br \/>\n*This page does not cover the system requirements needed to check-out and build NativeDriver or how to install and set up Eclipse. Information on this can be found in a variety of sources including books and the web.<\/p>\n<h4>Downloading and Building NativeDriver<\/h4>\n<p>First you need download the NativeDriver source code. Go to <a href=\"https:\/\/code.google.com\/p\/nativedriver\/wiki\/GettingStartedAndroid\" target=\"_blank\">GettingStartedAndroid<\/a> in Google Code and check-out the NativeDriver repository with SVN.(*During this process, a prompt for a username and password will appear when checking out the source code for iPhone. Leave them empty and press the Enter key.) <\/p>\n<pre>$ svn checkout http:\/\/nativedriver.googlecode.com\/svn\/trunk nativedriver<\/pre>\n<p>Change to the downloaded source directory and use the ant command to build the NativeDriver libraries. <\/p>\n<pre>$ cd nativedriver\/android\n$ ant\n<\/pre>\n<p>If it is successful, the following directory and files will be generated in the build directory.<\/p>\n<pre>$ cd build\/\n$ ls -la\n\u5408\u8a08 32816\ndrwxr-xr-x+ 1 testuser none        0 7\u6708  25 20:23 .\ndrwxr-xr-x+ 1 testuser none        0 7\u6708  25 20:23 ..\n-rwxr-xr-x  1 testuser none    15518 7\u6708  25 20:23 client.jar\n-rwxr-xr-x  1 testuser none 14267411 7\u6708  25 20:23 client-prejarjar.jar\n-rwxr-xr-x  1 testuser none  1764901 7\u6708  25 20:23 client-standalone.jar\n-rwxr-xr-x  1 testuser none     7660 7\u6708  25 20:23 common.jar\n-rwxr-xr-x  1 testuser none    76742 7\u6708  25 20:23 server.jar\n-rwxr-xr-x  1 testuser none 15047644 7\u6708  25 20:23 server-prejarjar.jar\n-rwxr-xr-x  1 testuser none  2407619 7\u6708  25 20:23 server-standalone.jar\n$\n<\/pre>\n<h4>Importing Sample Project<\/h4>\n<p>The downloaded NativeDriver repository contains code for a sample app and test. Use these to test integration with Remote TestKit. <\/p>\n<p>Start Eclipse and import the sample app and test code.<br \/>\nFollow the steps below to import.<\/p>\n<ul>\n<li>Click the \u201cFile\u201d -&gt; \u201cImport\u201d menu item.<\/li>\n<li>Select \u201cGeneral\u201d -&gt; \u201dExisting Projects into Workspace\u201d and click Next.<\/li>\n<li>Click Browse and select nativedriver\/android directory.<\/li>\n<li>Make sure that \u201candroid-test\u201d and \u201csimplelayouts\u201d have been added to \u201cProjects\u201d, and click Finish.<\/li>\n<\/ul>\n<div class=\"l-imgbox\"><img src=\"https:\/\/appkitbox.com\/en\/wp-content\/themes\/testkit-en\/images\/import_nativedriver_sampleapp_and_test_495x392.jpg\" \/><\/div>\n<p>Once import has been completed, it should look like this in Package Explorer.<\/p>\n<div class=\"l-imgbox\"><img src=\"https:\/\/appkitbox.com\/en\/wp-content\/themes\/testkit-en\/images\/import_nativedriver_project_zoom_495x512.jpg\" \/><\/div>\n<h4>Making the Sample App Testable with NativeDriver<\/h4>\n<p>To make the sample application testable with NativeDriver:<\/p>\n<p>First right click on the simplelayouts project sample app to open the properties, click Java Build Path on the menu to the left, check the boxes by Android 2.3.3* and server-standalone.jar, and click OK. *The GettingStartedAndroid document lists that Android SDK 2.2 or later is required for the simplelayouts sample application, so be sure to install the package for version 2.3.3 from Android SDK Manager beforehand.<\/p>\n<p>Set the Project Build Target to 2.3.3.<\/p>\n<div class=\"l-imgbox\"><img src=\"https:\/\/appkitbox.com\/en\/wp-content\/themes\/testkit-en\/images\/property_android_target_495x324.jpg\" \/><\/div>\n<p>Select Build Path, check the boxes by Android 2.3.3 and server-standalone.jar, and save.<\/p>\n<div class=\"l-imgbox\"><img src=\"https:\/\/appkitbox.com\/en\/wp-content\/themes\/testkit-en\/images\/link_server_to_sample_application_495x349.png\" \/><\/div>\n<p>Right click on the android-test sample test to open the properties, click Java Build Path on the menu to the left, check the boxes by client-standalone.jar and JUnit3, and click OK.<\/p>\n<div class=\"l-imgbox\"><img src=\"https:\/\/appkitbox.com\/en\/wp-content\/themes\/testkit-en\/images\/link_client_to_sample_test_495x3061.jpg\" \/><\/div>\n<h4>Setting up a Device in Remote TestKit<\/h4>\n<p>Since you have already set the Build Target for the simplelayouts sample app to 2.3.3 (see above), once you have begun renting\/started up the 2.3.3 device in Remote TestKit, select ADT\/DDMS\/abd under Device Function in the device window to enable integration with ADT\/DDMS\/abd. Then open the command-line tool and enter the following command to obtain the device ID of the attached device.<\/p>\n<pre>adb devices\n<\/pre>\n<p>This will return the following device ID. In the example below, the device ID is optimus_bright_l-07c.appkitbox.com:52439.<\/p>\n<pre>adb devices\nList of devices attached\noptimus_bright_l-07c.appkitbox.com:52439\tdevice\n<\/pre>\n<p>Next enter the following command to port-forward.<\/p>\n<pre>adb -s [deviceID] forward tcp:54129 tcp:54129 <\/pre>\n<div class=\"l-imgbox\"><img src=\"https:\/\/appkitbox.com\/en\/wp-content\/themes\/testkit-en\/images\/adb_forward_port_54129_495x184.jpg\" \/><\/div>\n<h4>Building and Installing the Application<\/h4>\n<p>Right click on the simplelayouts sample application and select \u201cRun as\u201d -&gt; \u201cAndroid Application\u201d to build and install the application.<\/p>\n<div class=\"l-imgbox\"><img src=\"https:\/\/appkitbox.com\/en\/wp-content\/themes\/testkit-en\/images\/rtk_nativedrvier_sampleapplication_254x495.jpg\" \/><\/div>\n<p>*If installation fails due to timeout, select Window -&gt; Preferences in the Eclipse menu and the Preferences dialogue box will appear. Then select \u201dDDMS\u201d under \u201dAndroid\u201d in the menu, increase the ADB connection timeout value (e.g. 10000) and try again.<\/p>\n<p>After confirming that the application has been installed in the rented device with Remote TestKit, run the following command to enable instrumentation and restart the application. <\/p>\n<pre>adb shell am instrument com.google.android.testing.nativedriver.simplelayouts\/com.<br \/>google.android.testing.nativedriver.server.ServerInstrumentation\n<\/pre>\n<p>If the message \u201cJetty started on port 54129\u2033 appears in the Eclipse logcat window, you are ready to run the test.<\/p>\n<div class=\"l-imgbox\"><img src=\"https:\/\/appkitbox.com\/en\/wp-content\/themes\/testkit-en\/images\/logcat_Jetty_started_495x135.jpg\" \/><\/div>\n<h4>Running the Test<\/h4>\n<p>Right click on the android-test sample test, select \u201cRun as\u201d -&gt; \u201cJUnit Test\u201d, and the test will start.<\/p>\n<div class=\"l-imgbox\"><img src=\"https:\/\/appkitbox.com\/en\/wp-content\/themes\/testkit-en\/images\/nativedriver_sample_test_result_495x354.jpg\" \/><\/div>\n","protected":false},"excerpt":{"rendered":"<p>How to use Remote TestKit with NativeDriver You can also use the test automation tool NativeDriver via Remote TestKit. NativeDriver is a testing framework specifically optimized for Android native applications. By using this framework in conjunction with Remote TestKit, you can carry out automated testing of native applications on a wide range of devices. *In [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":4939,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"support-template.php","meta":{"content-type":""},"categories":[6,5],"aioseo_notices":[],"acf":[],"_links":{"self":[{"href":"https:\/\/appkitbox.com\/en\/wp-json\/wp\/v2\/pages\/5044"}],"collection":[{"href":"https:\/\/appkitbox.com\/en\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/appkitbox.com\/en\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/appkitbox.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/appkitbox.com\/en\/wp-json\/wp\/v2\/comments?post=5044"}],"version-history":[{"count":0,"href":"https:\/\/appkitbox.com\/en\/wp-json\/wp\/v2\/pages\/5044\/revisions"}],"up":[{"embeddable":true,"href":"https:\/\/appkitbox.com\/en\/wp-json\/wp\/v2\/pages\/4939"}],"wp:attachment":[{"href":"https:\/\/appkitbox.com\/en\/wp-json\/wp\/v2\/media?parent=5044"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/appkitbox.com\/en\/wp-json\/wp\/v2\/categories?post=5044"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}