mobile app testing services, software testing company, app development companies, mobile app development services, iphone apps development, android app development company, mobile application development company
App Development

How to do mobile app automation testing using MonkeyTalk tool?

MonkeyTalk

MonkeyTalk is an open source mobile app automation testing tool for Android and iOS. MonkeyTalk is a simple-to-use tool which automates real, functional interactive tests for iOS, Android, Web/HTML5, Hybrid and Flex apps. This open source tool can be used for simple ‘smoke tests’ or for ‘data-driven test’ suites on native, mobile, and hybrid apps, real devices or simulators.

Moreover, automation saves time, it is reusable and repeatable. MonkeyTalk is an open source automation tool. It supports both Android and iPhone. It is very easy to learn and it’s a powerful functional testing tool.

Requirements to start testing with MonkeyTalk
  • Download and install Java
  • Download MonkeyTalk Pro
  • Need Eclipse or Android Studio to configure the source code

In order to record the script with MonkeyTalk, we need to configure the build with some dependencies.

The major component used for MonkeyTalk is the MonkeyTalkAgent. Any build including Android or iOS need to be integrated with Monkeytalk, otherwise, the tool cannot recognize the elements of the app. As a result, we cannot record or run the script on our test app. The build which is integrated with MonkeyTalkAgent is called as Instrumented build.

Instrumentation can be done in 2 ways as follows:

  • MonkeyTalkPro provides an inbuilt feature to instrument the build, which injects MonkeyTalkAgent to the built.
  • Otherwise, we can manually integrate the MonkeyTalkAgent by configuring the source code using eclipse or Android Studio before deploying the build.

Before we start configuring the source code, we need to install “AspectJ” plugin in eclipse. The procedures to install AspectJ plugin is available here. Once the plugin is installed, Now the open our project source code in eclipse.

Steps to instrument the Android build using eclipse as follows:

Step 1: Convert your Android project to AspectJ by right click the project name and select as follows.

Step 2: MonkeyTalk-agent.jar can be found in the “agents” folder in the MonkeyTalk package you downloaded earlier. The exact name of the jar might vary depending on the version, but it should always start with “MonkeyTalkagent”.

Step 3: Create a “libs” folder in your Android project, if you don’t already have one and Copy the monkeytalk-agent.jar into the libs folder.

Step 4: Right click on MonkeyTalk-agent.jar -> AspectJ Tools -> Add to Aspectpath.

Step 5: Update your AndroidManifest.xml to include the following two permissions:

Step 6: 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:

Step 6: Deploy your application to an Android device or emulator.

As a result, you will find the instrumented .apk in project’s bin folder. By using that .apk, we now start the test with MonkeyTalkIDE. (For Video tutorial Click here)

Step to be followed to create a test in MonkeyTalkIDE is as follows:

Step 1: Create new TestProject by selecting (File -> New -> Project -> General -> Project). Enter the Project name (eg. MyProject) and click finish.

Step 2: Now add Test to the project by right click on the project and select (New -> Script). Enter the name for the test (MyTest) and select the project to which needs to be added. Now open the test file which we created (say “MyTest.mt”).

Step 3: Now we have to import the instrumented .apk which we already created, by selecting menu (App -> Select a .apk file to test) or select using toolbar as below:

Step 4: After adding the .apk, choose any of the connected device or emulators to test.

Once the device is selected the console below will show the message like this:

Step 5: Now install the .apk in the selected device as follows:

Step 6: Now launch the app in connected device as follows:

Note: Once again click on connect device, as a result the record and playback button will be enabled to start the test.

Step 7: Now we can start recording by click on the record button.

Whatever we work on the test app will be recorded by MonkeyTalk and generate the test script as follows:

Our test script can be view and edit in 3 ways as follows:

  • Table view
  • MonkeyTalk Script
  • JavaScript

Step 8: Once the recording is done. Click on Stop button and click Play button to view the playback of the script. (Before clicking on Play button, relaunching the application is recommended).

Step 9: To do a complete test on our test app, we have to add some verify commands if needed.

Step 10: Test result can be viewed in the console window.

Advantages of Monkeytalk:
  • Open source Tool
  • Provide Record and Playback
  • Support both Android and iOS
  • Support Cross platform recording
  • Easy Readable Test script
  • Support Gestures
References:
  1. For more details Click here.
  2. How to generate instrumented .apk from Android studio? Click here.