Prerequisite tutorials"Eclipse with Android SDK - Installation Guide" from this blog. You'll may need this to help set up your environment. It also contains some "other topics" such as how to load an android app into Eclipse, install a .apk on the emulator, how to run the app etc.
You will need
- Windows 7 x64 - All instructions are for Windows users.
- Gorilla Logic - MonkeyTalk (free open source download)
- Android SDK (free open source download)
- Eclipse IDE with ADT plugin installed (other steps below).
Reason for using MonkeyTalkAndroid testing can potentially be a lot easier and faster with record / playback facilities and scripting. We can write our own scripts by hand but this is a time consuming task which requires repeating whenever the AUT changes.
Having a record / playback facility enables us to create a script as we browse the Android emulator / device and create a script without having to manually write any code. We can then repeat the tests over and over to load in data or check for defects. The scripts created can be edited manually and require little technical knowledge to modify. For this reason record / playback software is excellent for test teams composed of non-technical people who understand a software specification but do not know how to develop software. Many test teams enjoy using Selenium IDE for this job on a website but what about testing Android applications?
Several such tools exist for Android. One of these is MonkeyTalk SDK (free & open source), there is also BotBot (free & open source) and bitbar TestDroid (proprietary). This guide focuses exclusively on MonkeyTalk.
Getting MonkeyTalkTo use MonkeyTalk you need to set up an account with them. This is pretty straight-forward. Afterwards login and navigate to the download page and get MonkeyTalk IDE:
Unzip MonkeyTalk and place it at the root of the C: drive in a folder called "monkeytalk".
Take the MonkeyTalkIDE folder and place it in c:\program files , unless you are running the x86 version on an x64 system, in which case place it in c:\Program Files (x86).
Aspect JYou will need to install AspectJ to Eclipse. Go to Help > "Install new Software" > In Work with:
Several urls are needed to get the packages you need:
"AJDT Development tools" from: http://download.eclipse.org/tools/ajdt/37/update
(You may also need:
"Apache Maven" from: http://q4e.googlecode.com/svn/trunk/updatesite-iam/ )
Setting up a MonkeyTalk Project and Running a TestImport a suitable program to test in Eclipse, anything simple with a couple of buttons and input boxes will do.
Convert to Aspect JRight click your project in Eclipse > Configure > "Convert to AspectJ"
Nothing wil appear happen except some visible folder changes.
Create a libs folder in the Android project if none exists.
Navigate to the MonkeyTalk agent for Android, located at:
Copy the android agent into the libs folder from c:\monkeytalk\agents\android
Right click on MonkeyTalk-agent.jar > AspectJ Tools > Add to Aspectpath > You will see some folder changes happen.
Update your AndroidManifest.xml to include the following two permissions:
To do this, open the manifest file and add these lines under the root element <manifest> :
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.GET_TASKS" />
Update the project properties (right-click on the project > Properties > Java Build Path), select the Order and Export tab, and check the checkbox next to the AspectJ Runtime Library to export it.
Run the project on a suitable emulator (i.e. same api version).
Create the MonkeyTalk Project in IDEOpen the MonkeyTalk IDE where scripts will be recorded / played. You may want to create a shortcut to this application.
Create a new MonkeyTalk project by giving it a name and choosing the workspace where all of these will go.
Right click the new project in the MT IDE and select new Script. Give it a filename and click Finish.
Connecting the MonkeyTalk IDE to the EmulatorOpen the MonkeyTalk IDE > Click the test > Click the Android drop down next to the play button > Select "Android Emulator / Tethered Device" > The first time through will ask you to enter the location of the Android SDK > after you exit this screen, click on the Android icon again and you will get this message in the console if successful:
"Connection set to Android Emulator or Tethered Device"
If not, ensure that the emulator is running and that the app is visible that you want to test.
Recording through the MonkeyTalk IDELoad the emulator you want to use with MT installed as in previous steps. Load the application you want to test on the emulator.
Connect as in previous steps.
Go to the running emulator > Click the steps you need to record in the emulator (similar to Selenium IDE) > Click stop when finished > Click play to play back the test and watch it performing the steps you ran.