{"id":5740,"date":"2016-03-17T11:42:23","date_gmt":"2016-03-17T02:42:23","guid":{"rendered":"https:\/\/appkitbox.com\/en\/?page_id=5740"},"modified":"2022-08-26T17:15:30","modified_gmt":"2022-08-26T08:15:30","slug":"building-a-smartphone-test-platform-by-using-rtk-and-open-source-software","status":"publish","type":"page","link":"https:\/\/appkitbox.com\/en\/knowledge\/building-a-smartphone-test-platform-by-using-rtk-and-open-source-software\/","title":{"rendered":"Building a Smartphone Test Platform by Using RTK and Open Source Software"},"content":{"rendered":"<style>\nmain .wrappedtopicnormal {margin-bottom:30px;}<br \/>\nmain p+h5 {margin-top:30px;}<br \/>\nmain p+h6 {margin-top:30px;}<br \/>\n.pre {white-space:pre;}<br \/>\n.pre br {display:none;}<br \/>\n<\/style>\n<p>Building a site for mobile testing platforms with Jenkins, Ruby, and RTK<\/p>\n<p style=\"text-align:right;\">Hiroki Maruchi and Shoichi Iwai, GBA Co., Ltd.<\/p>\n<p class=\"listtitle\">Table of Contents<\/p>\n<ol style=\"margin-bottom:50px;\">\n<li><a href=\"#t1\">Introduction<\/a><\/li>\n<li><a href=\"#t2\">Testing an RTK Rental Device with a Jenkins Job<\/a><\/li>\n<li><a href=\"#t3\">Checking the Screen on the Build Result<\/a><\/li>\n<li><a href=\"#t4\">Further Application: Improving Test Development \"Continuously\"<\/a><\/li>\n<li><a href=\"#t5\">Conclusion<\/a><\/li>\n<\/ol>\n<h3 id=\"t1\">1. Introduction<\/h3>\n<p>In one of the previous articles, \"Using Jenkins for the First Time,\" we installed Jenkins, and ran a job.<br \/>\nIn the previous article, \"Programming a Smartphone Test in Ruby,\" we used RTK Thrift API and from the test script created by the user, we rented a smartphone on RTK and ran an app on the device. We then captured the screen of the run result.<\/p>\n<p>This article sums up that procedure. The system configured by the laptop PC in the below image uses several smartphones in RTK, and runs the app build and the test.<\/p>\n<h3 id=\"t2\">2. Testing an RTK Rental Device with a Jenkins Job<\/h3>\n<p>In the section \"Creating a Job: Build an Android Studio Project\" in one of the previous articles titled \"Using Jenkins for the First Time,\" we built an Android project and installed it on an emulator.<\/p>\n<p>In the previous article, \"Programming a Smartphone Test in Ruby,\" we used the RTK Thrift API feature and accessed RTK via the Internet with the Ruby test script. We also rented a smartphone in the RTK cloud and controlled it to install an app as well as capture screens of the Web and the app.<\/p>\n<p>Here, we combine those two procedures and create a Jenkins job to run a test on a smartphone that uses RTK. The following is an example of the job setting values. Basically, we are only adding the content of the test script for the app build to the content we introduced in the previous article.<\/p>\n<h4>Creating a job<\/h4>\n<h5>Set up<\/h5>\n<p>Create a new job.<br \/>\nInput a job name and select <span class=\"redletter\">Freestyle project<\/span>.<\/p>\n<h5>Project name<\/h5>\n<p>Here, we named the project \"test_calculator_004\".<\/p>\n<h5>Specifying the source code location<\/h5>\n<div class=\"wrappedtopicnormal\" style=\"overflow-x:auto;\">\n<p class=\"pre\">Advanced project option<br \/>\n&gt; Use a custom workspace\u2026 Check<br \/>\n&gt; Directory field: \/Users\/hiroki\/AndroidStudioProjects\/calculator_002<\/p>\n<p class=\"pre\">Build<br \/>\n&gt; Run the shell<br \/>\n&gt; Command field: \/gradlew build # Run the build<\/p>\n<p class=\"pre\">Build<br \/>\n&gt; Run the shell<br \/>\n&gt; Command field: ruby test_004.rb # Run the RTK test<\/p>\n<p class=\"pre\">Post-build Actions<br \/>\n&gt; Save the result<br \/>\n&gt; Field for the file to be saved: **\/*.apk<\/p>\n<\/div>\n<div class=\"l-imgbox\"><img loading=\"lazy\" src=\"https:\/\/appkitbox.com\/en\/wp-content\/uploads\/sites\/2\/Setup_001-3.png\" alt=\"Setup_001\" width=\"1003\" height=\"807\" class=\"alignleft size-full wp-image-5742\"><\/div>\n<div class=\"l-imgbox\"><img loading=\"lazy\" src=\"https:\/\/appkitbox.com\/en\/wp-content\/uploads\/sites\/2\/Setup_002-3.png\" alt=\"Setup_002\" width=\"1003\" height=\"636\" class=\"alignleft size-full wp-image-5743\"><\/div>\n<div class=\"l-imgbox\"><img loading=\"lazy\" src=\"https:\/\/appkitbox.com\/en\/wp-content\/uploads\/sites\/2\/Setup_003-3.png\" alt=\"Setup_003\" width=\"1002\" height=\"832\" class=\"alignleft size-full wp-image-5744\"><\/div>\n<p>Once setup is complete, click the <span class=\"redletter\">Save<\/span> button to save the job.<\/p>\n<h5>Running a job<\/h5>\n<p>Click <span class=\"redletter\">Build Now<\/span>. The job runs.<br \/>\nWhile the job is running, you can display content on the console. Finally, <span class=\"redletter\">Finished: SUCCESS<\/span> is displayed and the job completes running successfully.<\/p>\n<div class=\"l-imgbox\"><img loading=\"lazy\" src=\"https:\/\/appkitbox.com\/en\/wp-content\/uploads\/sites\/2\/Console_001-3.png\" alt=\"Console_001\" width=\"1271\" height=\"1048\" class=\"alignleft size-full wp-image-5745\"><\/div>\n<div class=\"l-imgbox\"><img loading=\"lazy\" src=\"https:\/\/appkitbox.com\/en\/wp-content\/uploads\/sites\/2\/Console_002-3.png\" alt=\"Console_002\" width=\"1271\" height=\"1050\" class=\"alignleft size-full wp-image-5746\"><\/div>\n<div class=\"l-imgbox\"><img loading=\"lazy\" src=\"https:\/\/appkitbox.com\/en\/wp-content\/uploads\/sites\/2\/Console_003-3.png\" alt=\"Console_003\" width=\"1271\" height=\"510\" class=\"alignleft size-full wp-image-5747\"><\/div>\n<h5>Displaying the result<\/h5>\n<p>In the same manner as previously, after the job completes, the result of whether the job ran successfully or not is displayed using green and red traffic lights.<\/p>\n<div class=\"l-imgbox\"><img loading=\"lazy\" src=\"https:\/\/appkitbox.com\/en\/wp-content\/uploads\/sites\/2\/Result_005-3.png\" alt=\"Result_005\" width=\"1002\" height=\"594\" class=\"alignleft size-full wp-image-5748\"><\/div>\n<p>The image of the captured result is saved in the project directory \"app\/build\/reports\/rtk\".<\/p>\n<div class=\"l-imgbox\"><img loading=\"lazy\" src=\"https:\/\/appkitbox.com\/en\/wp-content\/uploads\/sites\/2\/Result_0041-3.png\" alt=\"Result_004\" width=\"424\" height=\"562\" class=\"alignleft size-full wp-image-5749\"><\/div>\n<p>Thus, you can confirm whether the app ran successfully on the test smartphone without the intervention of a person. However, the screen capture of the result is only placed on the local directory of the development PC. So that all members can check from Jenkins, we would like some more features.<\/p>\n<h3 id=\"t3\">3. Checking the Screen on the Build Result<\/h3>\n<h4>Job Modification: Checking the Screen on the Jenkins Web Site<\/h4>\n<p>For the Jenkins job in the previous section, we ran an app on the smartphone we rented on RTK and locally downloaded the run result as a screen file. However, the screen file that is the test result resides on the local PC.<\/p>\n<p>This time, let's check the result screen file on Jenkins.<br \/>\nTo do this, all we have to do is save the image to <span class=\"redletter\">Save the result<\/span> in the settings.<\/p>\n<h5>Set up<\/h5>\n<div class=\"wrappedtopicnormal\" style=\"overflow-x:auto;\">\n<p class=\"pre\">Post-build Actions<br \/>\n&gt; Save the result<br \/>\n&gt; Field for the file to be saved: **\/*.apk, **\/capture_*.jpg \u2026 Also make sure to save the images.<\/p>\n<\/div>\n<div class=\"l-imgbox\"><img loading=\"lazy\" src=\"https:\/\/appkitbox.com\/en\/wp-content\/uploads\/sites\/2\/Setup_006-3.png\" alt=\"Setup_006\" width=\"1018\" height=\"599\" class=\"alignleft size-full wp-image-5750\"><\/div>\n<p>In the same manner as previously, let's run the job.<br \/>\nThe capture of the result will also be displayed as an item in <span class=\"redletter\">Build Artifacts<\/span>.<\/p>\n<div class=\"l-imgbox\"><img loading=\"lazy\" src=\"https:\/\/appkitbox.com\/en\/wp-content\/uploads\/sites\/2\/Result_007-3.png\" alt=\"Result_007\" width=\"1019\" height=\"750\" class=\"alignleft size-full wp-image-5751\"><\/div>\n<p>You can display the image of the result in a browser by clicking the link.<br \/>\nSimply put, previously, you could only view the result on the local PC, but now you can share the result with other Jenkins members as soon as the job completes.<\/p>\n<div class=\"l-imgbox\"><img loading=\"lazy\" src=\"https:\/\/appkitbox.com\/en\/wp-content\/uploads\/sites\/2\/Result_008-3.png\" alt=\"Result_008\" width=\"1385\" height=\"735\" class=\"alignleft size-full wp-image-5752\"><\/div>\n<h3 id=\"t4\">4. Further Application: Improving Test Development \"Continuously\"<\/h3>\n<p>In the section above, we showed that we can perform smartphone app development in any environment by using only a small number of the RTK Thrift API features. Depending on the type of development and the team, there are almost limitless demands. It goes without saying that all the features cannot be introduced here. We give you some tips as follows.<\/p>\n<h4>Using the RTK Thrift API features<\/h4>\n<p>The following basic features are available in RTK Thrift API:<\/p>\n<ul>\n<li>Device rental\/automatic extension feature<\/li>\n<li>Web page capture<\/li>\n<li>Virtual adb, Wifi, GPS settings<\/li>\n<li>Screen capture, device rotation<\/li>\n<li>Video recording<\/li>\n<\/ul>\n<p>Only a small number of features were used in this example. The full operation can be recorded as a video as well to meet the purpose the user is developing the app. Furthermore, RTK Thrift API is currently being actively developed. In the near future, features will be added and it will be improved. Please check the RTK Web site for added features and specifications.<\/p>\n<h4>Using Jenkins' features<\/h4>\n<p>Builds and tests are run every day and git commit can be run as an event. This can be set comparatively easily in <span class=\"redletter\">Build Triggers<\/span> and <span class=\"redletter\">Source Code Management<\/span> in the Jenkins job settings.<\/p>\n<p>In this article, the developer clicks a button to start builds and tests. By converting to the procedure stated above, the developer does not need to be involved manually and specialization can be avoided. Additionally, when making a commit or a change, you can always check whether it passed or failed, and you can introduce quality engineering-type methods, such as regularly performing multiple tests, gathering statistics, and so forth.<\/p>\n<h4>Using the user test script feature<\/h4>\n<p>If you want to add a feature that is not in RTK Thrift API or Jenkins, there are times when you can use the user test script to add that feature.<\/p>\n<p>For example, you can specify the model to rent on RTK, test various models individually, and so on.<\/p>\n<p>In the user test script indicated in this example, there is a filter method to easily select a device to rent (select_device method). We think that this will be helpful for you. Moreover, in order to test the specified number of devices, by including a loop, subsequent tests can also be created relatively easily.<\/p>\n<p>In any case, in order for the entire development team to improve testing, it is important to use a programming language for the user test script that is easily read and maintained by every member including app developers and testers. In this example, Ruby is used. Ruby is used widely in other open source development support software like Chef and ServerSpec as well and we think it is a good option.<\/p>\n<h3 id=\"t5\">5. Conclusion<\/h3>\n<p>In this article, we created a simple system that automates the process up until the testing of the smartphone by using RTK and open source software multiple times.<\/p>\n<p>RTK provides a system in the development process in which manual intervention in test processes involving an actual device are unnecessary. In this article, we were able to relatively easily support actual device testing by just adding test script to the Jenkins scenario. Like this example, we can now easily embed in the automated test process the device testing that we could not perform because it required manual operations in the past. By using RTK, the precision of automated testing increases, and output can also be increased without spending much on setup costs.<\/p>\n<p>In smartphone app development in the past, at the phase testing the final product, a large number of samples were used and a great deal of blood, sweat, and tears were expended in the final check before delivery. This achieves a simple shape like a picture. We believe that this shows that the manufacturing of smartphones can be greatly changed by RTK.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Building a site for mobile testing platforms with Jenkins, Ruby, and RTK Hiroki Maruchi and Shoichi Iwai, GBA Co., Ltd. Table of Contents Introduction Testing an RTK Rental Device with a Jenkins Job Checking the Screen on the Build Result Further Application: Improving Test Development &#8220;Continuously&#8221; Conclusion 1. Introduction In one of the previous articles, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":5622,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"general-template.php","meta":{"content-type":""},"categories":[14],"aioseo_notices":[],"acf":[],"_links":{"self":[{"href":"https:\/\/appkitbox.com\/en\/wp-json\/wp\/v2\/pages\/5740"}],"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=5740"}],"version-history":[{"count":3,"href":"https:\/\/appkitbox.com\/en\/wp-json\/wp\/v2\/pages\/5740\/revisions"}],"predecessor-version":[{"id":415531,"href":"https:\/\/appkitbox.com\/en\/wp-json\/wp\/v2\/pages\/5740\/revisions\/415531"}],"up":[{"embeddable":true,"href":"https:\/\/appkitbox.com\/en\/wp-json\/wp\/v2\/pages\/5622"}],"wp:attachment":[{"href":"https:\/\/appkitbox.com\/en\/wp-json\/wp\/v2\/media?parent=5740"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/appkitbox.com\/en\/wp-json\/wp\/v2\/categories?post=5740"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}