Wednesday, 7 January 2015

Running Monkey Talk on Android

The feature tests are the tests used to replace the human interaction with the machine. They simulates user click and swipes on the screen and then, get the results. This is very useful because it could detects errors that cannot be detected by simple unit tests.

In this sense, there is a tool called Monkey Talk. It is provided by Cloud monkey which by running a set of scripts called Monkey Scripts, which is based on JavaScript, simulates all the possible actions that a user can perform. It works both with simulated and physical devices and the same script works for Android and iOS. Another cool feature is with its IDE, the user can record the action so, there is no need to coding to create a test.

Since Monkey Talk has its own IDE which does most of the work, the first step to use it is download and install the Monkey Talk IDE, which is based on eclipse.

Once it is downloaded and installed, we should modify a bit the project to connect the IDE with the app.

1. Download the AspectJ Development Tools plugin for eclipse.
1.1 Find the right download link depending on your eclipse version from the follow page:

For different version of eclipse, they have different download links. If you are using the version 4.4(Luna), this is the link:

1.2 Once we get the right link, copy it and go to eclipse, click on Help -> Install New Software.
1.3 Paste the link and click on Enter.
1.4 Select all the packages and click on Next, accept the contract and finish.

2. Convert the Android Project to AspectJ project
Now the unique thing you should do is right click on your project, select Configure -> Convert to AspectJ project.

If you don't see this option check if AspectJ has been installed correctly. If you still don't see it, try to restart eclipse.

If you have libraries that are used by your main project, you don't have to convert them. By converting the main project to AspectJ project will be enough.

3. Includes the Monkey talk Agent library
3.1 Copy the library
From the folder downloaded from Monkey talk, there is a folder called agent. Inside that folder there is another folder called android. It contains the jar file called monkey-agent and the actual version of it.  Copy that library to the lib folder in the Main Android project.

3.2 Now from the eclipse, refresh the project and find the monkey agent library under lib folder. Right click on it and select AsjectJ Tools -> Add to Aspectpath

4. Update the permissions
The bad thing about Monkey talk is it add new permissions. It requires two permissions: Internet and Get task. To do it, add this two lines to your Android Manifest file:

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.GET_TASKS" />

5. Export libraries
5.1 Right click on the main project and select "Properties"
5.2 On the pop-up windows, select "Java Build path"
5.3 On the right side, select the tab "Order and export"
5.4 Check the "AspectJ Runtime Library"
5.5 Beside this, try to also check the "monkeytalk-agent.jar". If by exporting the Monkey talk agent jar you see "Dextification error", you should uncheck it.

With this you should be able to compile and run your project, which include the Monkey talk agent in it. To test it, just open the Monkey talk IDE and click on the Android button at the top. If you have set Monkey talk correctly in your project, you will be able to see the record and play button near tot he Android button as follow image.

Here is a short video

Cloud Monkeys - Installing the MonkeyTalk Android Agent

No comments:

Post a Comment