This blog post illustrates how to automate testing of cross-platform apps implemented with MonoTouch for iOS and Mono for Android with Ranorex.
- Infrastructure
- Make Your “MonoTouch” (iOS) App Testable with Ranorex
- Make Your “Mono for Android” App Testable with Ranorex
- Conclusion
Infrastructure
MonoTouch and Mono for Android, both developed by Xamarin, are commercial implementations of Mono – a cross-platform implementation of C# – for iPhone and Android-based smartphones.
Using these two implementations it’s easy to reuse most of your existing code when porting from Android to iOS or vice versa. Next to that it’s possible to import existing .NET libraries and to use them in your Android/iOS apps.
Ranorex supports test automation for both, Mono Touch and Mono for Android. Simply follow the steps below to make your cross-platform app testable.
Make Your MonoTouch (iOS) App Testable with Ranorex
To instrument your MonoTouch app you simply have to add the Ranorex automation library for iOS to your MonoTouch project as native library.
Make Your Mono for Android App Testable with Ranorex
To instrument your Mono for Android app simply follow the step by step instructions below.
- Add the Ranorex automation library for Android (<RanorexInstallDir>\bin\RxEnv\Android\Ranorex.jar) to your Mono for Android project.



- Open the properties of the added file and set the build action to “AndroidJavaLibrary”.


- Download the file RanorexAndroidMonoInstrumentation.cs and add it to your project (the same way as described in the first step).
- Add the following lines of code to each activity in your project:
public override bool DispatchKeyEvent (KeyEvent e) { Ranorex.RanorexAndroidMonoInstrumentation.dispatchKeyEvent(e); return base.DispatchKeyEvent (e); } protected override void OnResume () { base.OnResume (); Ranorex.RanorexAndroidMonoInstrumentation.onResume(this); } protected override void OnPause () { base.OnPause (); Ranorex.RanorexAndroidMonoInstrumentation.onPause(this); } - Open the properties of your project and add a new “Android Manifest” in the “Mono for Android Application” area.

- Add “(RxInstrumented$4.x.x)” to the version name (whereas 4.x.x is the Ranorex version you are using) and activate the check boxes “INJECT_EVENTS” and “INTERNET” in the “Required permission” area.

Conclusion
Following these simple step by step instructions will make your MonoTouch and Mono for Android apps accessible for Ranorex and nothing should be standing between you and your robust cross-platform test automation.
To get started with mobile test automation, have a look at the chapters “Android Testing” and “iOS Testing” in our user guide.
Tags: Accessibility, Code Samples, Cross-Platform, Library, Technology



Subscribe