MonkeyRunner learning for android automated testing (1)

Source: Internet
Author: User

Here, I just want to record my learning experience and hope to give some new users some inspiration and spend less time exploring. If there is any inaccuracy, I would like to express my gratitude.
The android sdk integrates three simple tools for automated testing: Monkey, MonkeyRunner, and Robotium. All three testing tools are based on black box testing. Monkey is relatively simple. It only writes several lines of commands under cmd to perform simple stress tests on the program to be tested. The Robotium test tool has only one Solo class in total, which provides many methods that can be used to operate the test device. MonkeyRunner is relatively powerful among the three tools.
The MonkeyRunner test tool is mainly used to compile a Python program to install an android program or test package. By simulating some click operations on the program, to test the stability of a program and easily record problems through screenshots.
The Monkeyrunner tool is written using Jython (a Python implementation in Java programming language. Jython allows MonkeyrunnerAPI to easily interact with the Android framework. As for what is Python, Baidu is a powerful object-oriented programming language that can run across platforms. Of course, we use the MonkeyRunner testing tool. It is not necessary to study the Python language first. I am afraid we have not had much time in our actual work. We only need to understand some common Python programming specifications. (These will be given in combination with the code later ).
Now we will focus on how to configure the next Monkeyrunner's working environment.
If you simply use the MonkeyRunner test tool, there is no need to download a Python version installer to install it, or integrate a python plug-in the external ose, it is used to debug Python programs. The integration of plug-ins in eclipse is far from directly using Notepad or Notepad and other editing tools. Because Monkeyrunner has only three classes (MonkeyRunner, MonkeyDevice, and MonkeyImage ), there are not so many methods that give you the advantage of automatically prompting when writing programs in eclipse, and sometimes there are some headaches between plug-ins and eclipse versions. Therefore, only one notepad is enough.
To put it bluntly, since it is an android test, you must have been in a development environment with android (Baidu is not available ). Android development inevitably requires some development tools under android sdk tools. You can configure a ANDROID_HOME variable in the system environment variable to add the installation path of your android SDK. For example, my path is G: \ android03 \ android-sdk-windows. If you have already configured the ANDROID_HOME variable, you only need to add this statement to the PATH variable of your system variable: % ANDROID_HOME %/tools; in fact, it is equivalent to adding the PATH pointing to android sdk tools to the PATH variable.
After adding it, You can directly run the: monkeyrunner command in cmd and press Enter. If the version information of monkeyrunner appears, it indicates that your monkeyrunner environment has been configured successfully. (For example)

 
Sometimes, after you configure it, NOCLASSDefFound errors may occur. For example:

This is because a ChimpChat. jar file is missing from your sdk and the latest aster compressed package. This is the runtime environment package for android testing. Decompress this package and find aster \ dist \ jar \ chimpchat in the following path. jar, and then put chimpchat. copy jar to the bin directory under the tools directory in your android sdk, and then run the monkeyrunner command.

After configuration, you can run the monkeyrunner Python test file you wrote by running the monkeyrunner command in cmd.
For example, monkeyrunner e: \ test. py.
Write it here today. I don't like staying up late. You should pay attention to your health.

Author: fengbo sea

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.