Test Open source China Android client using Calabash

Source: Internet
Author: User

Calabash-android is an android-enabled UI Automation testing framework that has been described in the "Chinese Win7 successfully installed Calabash-android step", a blog post trying to test a real-world application: Open source Chinese client. The goal is to learn Calabash test tools together with you.

test environment and source preparationLet's introduce oschina.net.

Oschina In addition to the website, there are three platforms mobile client:

Http://www.oschina.net/app

The client is open source!

So what can open source do for you?

I am learning to use calabash-android, to find a suitable app to be tested, usually on the mobile phone open source China this app with pretty handy, so chose it, once again special to open source China's development engineer thanks!

Environment Preparation: adt+calabash-android

can refer to:
Successful installation of calabash-android steps under Chinese Win7

Download Oschina/android-app Source code

First to Http://git.oschina.net/oschina/android-app,

The way you download the source code is as follows:

    1. You can click "Download Zip" directly
    2. Copy the Git repository url:https://git.oschina.net/oschina/android-app.git, and then open windows > Opens perspective > in Eclipse/adt Other ... > Get resporsitory exploring,clone Source code

After importing into ADT, the source code is as follows:

Several problems in compiling and running Oschina/android-app in adt-bundle-20140702

Issue 1: the API version of adt-bundle-20140702 is 20, so to modify Project.Properties:
target=android-15Change intotarget=android-20

Issue 2: source code is using obsolete Class:android.webkit.CacheManager
The Android.webkit.CacheManager is used in the Oschina-android-app/src/net/oschina/app/appcontext.java
So you have to disable the relevant code:

61 lines:

Import Android.webkit.CacheManager;

Rows 1503 to 1509:

      File File = Cachemanager.getcachefilebasedir ();      if (file = null && file.exists () && file.isdirectory ()) {  //for          (file Item:file.listFil ES ()) {  //              item.delete ();          }  //          file.delete ();  //      }

Problem 3:run as Android Application error: Installation Error:install_failed_version_downgrade
The reason: The mobile phone has installed an open source China's 1.7, 7.0 version, and ADT to download the 1.7.6.9 version, the Android system does not allow the installation of an older version than the installed version, so from the phone to uninstall the existing 1.7.7.0 version.

ADT compiles and uploads Oschina/android-app to the phone

Run as Android application > select Connect to PC USB Phone > OK

Calabash Test StepsFirst, confirm that Oschina/android-app declares the right to access the network

The following line should be in the androidmanifest.xml of the Oschina/android-app project:

<uses-permission android:name= "Android.permission.INTERNET"/>
Create the Calabash directory in the Oschina/android-app root directory

Enter the source code root of Oschina/android-app under the command line:

D:\GIT\OSCHINA&GT;CD Android-appd:\git\oschina\android-app>dir Volume Serial number is 9823-ab19 Directory of D:\git \oschina\android-app2014/09/01 20:26 <DIR> 2014/09/01 20:26 <DIR>.                2014/09/01 20:21 783. classpath2014/09/01 20:21 <DIR> git2014/09/01 20:21  gitignore2014/09/01 20:21 822. project2014/09/01 20:21 <DIR> settings2014/09/01 20:21 10,829 androidmanifest.xml2014/09/01 20:21 <DIR> assets2014/09/01 20:42 &LT;DIR&G          T            bin2014/09/01 20:26 <DIR> gen2014/09/01 20:21 <DIR> libs2014/09/01 20:21 18,092 license.txt2014/09/01 20:21 1,424 proguard.cfg2014/09/01 20:41 563 project.properties2          014/09/01 20:21 4,183 readme.md2014/09/01 20:21 <DIR> res2014/09/01 20:21 <DIR> SRC 8 FIle (s) 36,760 bytes Dir (s) 133,131,993,088 bytes freed:\git\oschina\android-app> 

To create the Calabash directory:

D:\git\oschina\android-app>mkdir Calabash

Create cucumber skeleton:

D:\GIT\OSCHINA\ANDROID-APP>CD calabashd:\git\oschina\android-app\calabash>calabash-android Gen----------Question----------I ' m about to create a subdirectory called Features.features would contain all your Calabash Tests. Please hit return to confirm this ' s what you want.-------------------------------------Info----------Features subdirectory created.---------------------------D:\git\oschina\android-app\calabash>dir Volume Serial number is 9823-ab19 Directory of d:\git\oschina\android-app\calabash2014/09/01  21:54    <DIR>          . 2014/09/01  21:54    <DIR>          . 2014/09/01  21:54    <DIR>          features               0 File (s)              0 bytes               3 DIR (s)  133,131,988,992 Bytes Freed:\git\oschina\android-app\calabash>

Edit D:\git\oschina\android-app\calabash\features\my_first.feature:
Initial content:

Feature:login Feature  scenario:as A valid user I can log into my app when    I press "Login" then    I see "welcom E to coolest app ever "

The first line feature:xx, the second row of Scenario:yy is for people to read, so casually fill in any Chinese and English content can be
The key content is the third line when I press. and line fourth then I see: This is for cucumber software identification.
When followed by an action statement, then followed by a content check statement

Try the following changes first:

Feature: Start open source China  Scenario: After launching the app, you can see the software version update information then    I saw "software version update"

Running Calabash-andriod Run

D:\git\oschina\android-app\calabash>calabash-android Run D:\git\oschina\android-app\bin\ oschina-android-app.apk


The test failed because then the default wait time was only 2 seconds, and the open source China app started longer.
Ansicon failed to display Chinese: "Software version Update", this is resolved later.

As instructed by HTTPS://GITHUB.COM/CALABASH/CALABASH-ANDROID/BLOB/MASTER/RUBY-GEM/LIB/CALABASH-ANDROID/CANNED_STEPS.MD, you can specify to wait a few seconds:

Feature: Start open source China  Scenario: After you launch the app, you can see the software version update information then    I wait for the seconds then    I saw "software version update"

On the phone to see the open-source China post-launch screen:

Button "Update Now" why is it red? Resolved later.

To this step, calabash test open-source China Android Client environment has been established, then students can happily try canned_steps.md in the various predefined steps.

I will continue to complete this test case, everyone together progress!

Test Open source China Android client using Calabash

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.