BDD Android UI testing framework? - android

I'm looking at using Frank for UI testing our iOS application(s). Is there a similar library with support for Android? I'm currently using Robotium, but thought it would be nice to be able to specify tests in the same format across both platforms.
Would it be possible to get something like JBehave to run on Android?

As scompt.com said. The project is now officially open sourced and is called Calabash.
I wrote a short blog post about it:
http://blog.lesspainful.com/2012/03/07/Calabash-Android/
Calabash is also available on iOS and with a bit of work and two similar apps you can run the same feature on iOS and Android.
You can read more general stuff about Calabash here:
http://blog.lesspainful.com/2012/03/07/Calabash/

The guys from lesspainful.com have open sourced some of their special sauce on github. It lets you do cucumber testing on android in the emulator and local devices. Because it's the same code that they're running for their service, you should be able to test your features on multiple devices if you sign up.

Could you use Cuke4Duke to drive Robotium? Or use JRuby/Cucumber to drive Robotium?

No, robotium is a BDD on dvm not jvm thus no driver exists with jvm frameworks such as jbehave, etc

I've recently started using www.LessPainful.com - there are some limitations (you can't write your own steps) and it's quite an early stage company, but so far the testing has at least proved useful, especially with different screen sizes, plus they've automated some good things like orientation (I think they use motors on real phones!).
(for reference on iOS we're using Frank - https://github.com/moredip/frank- and on WP7 we've written our own - https://github.com/Expensify/WindowsPhoneTestFramework)

I've been able to open-source my work in this area:
https://bitbucket.org/proxama/windows_android_cucumber_runner
https://bitbucket.org/proxama/android_cucumdroid
It allows you to write your own features and steps to exercise the UI automator. This means it runs all on the device.
It's probably not as easy to use as it could be but the Windows gui app is designed to wrap the ANT tasks that make it actually run.

I have tested my app using MonkeyTalk. It may help you. https://www.cloudmonkeymobile.com/monkeytalk

Related

Portable Mobile/Tablet application proof of concept

I need to develop a portable application mainly for Windows 8.1 and iPad, but could be expanded for Android, WP and iOS later.
The application consists of calling web services to display data in grids and it contains CRUD operation, and it may save some local data for offline mode then synchronizes later when connectivity is up.
I'm torn between too many solutions, I need your advise for better solution.
1- Solution 1: Go Native for each OS (VS for Windows 8.1 [RT and pro] and xCode for iPad): this solution requires code duplication, logic and UI.
2- HTML5 with WebView app: I think this is a weak solution especially that we have local storage, checking for connectivity and calling ws ...
3- Using Xamarin: I think Xamarin does not support WinRT or Windows 8.1 to share logic code between iPad and Windows 8.1
4- Using Xamarin.Forms: Building the UI is tough and also it does not support Windows 8.1.
From your perspective, what is the best solution? please advices if you have any other proof of concept.
Many Thanks.
Most of the html/hibrid frameworks like Cordova (cordova.apache.org), Ionic (http://ionicframework.com/), etc, uses a native WebView on Android. Until Kitkat the performance of WebView is not production-ready and if you've a list with a lot of elements, the scroll experience is really bad.
If you want to do a simple proof of concept, prototype or whatever, I think that html frameworks are a good alternative. But if you are going to put your bussiness on top of one of this framworks, I would not recommend.
There is an alternative to embed a Chrome using Cordova & crosswalk (https://crosswalk-project.org/documentation/cordova.html) but you will end with an APK ~40Mb for a simple hello world.
Just my 2 cents. I don't see a point in using libraries that are unsupported across the platforms you plan to release and support on. Personally, I'd code natively for each platform. While this takes a lot of work, if you have to ask for direction on which path you want to take your application, then this type of project sounds more like a "you reap what you sow" application. Also, you'll be able to directly support each problem without having to wait for patches, but there are 2 sides to that coin as well. Your opportunity cost is missing future features the library will provide, if it's worth it to you.
If you aim at quality, going native is the only way... You can reduce the amount of work like Google is doing: writing the business logic and unit tests in Java, then converting it to ObjC with J2ObjC and to Javascript with GWT.
In your case, being that Java is a dumbed-down version of C#, you can easily find tools to convert to the latter, finding yourself with native business logic for every platform! That should account for 50%-70% of the codebase...
I think going with HTML5 with webapp view is better option.
Using Cordova (Phonegap) most of the native features are easily achievable in HTML webapp.
PhoneGap Platform Guide
Alot of other plugins are available for the advances features like BLE, NFC.
Calling webservice is really not an issue in HTML5.
Simple ajax is enough, however now a days many advanced frameworks are available which makes your work easy. One of the best among them is Angular JS(maintained by Google ).
Angular JS
For database you can access native database of the target OS or SQLite db of the mobile device.
You can check this link
Storage options
So developing a webapp can be a more efficient solution in your case. It can be best way for you as per my view point. However, you can do some R & D and can find the appropriate for you.

Should I use Android Instrumentation to write unit test?

I have read some articles about unit testing in Android including the official documentations and wrote some demos, it is complicated and slow because it must run on a device or emulator. Should I continue using it or find another option?
Usually a good test should run on the target device. Thats why my answer is: yes you should continue using it. If you test on an emulator or something like that there could be some little differences that would cause some different behaviour than on the real device (espacially if you use some hardware components).
If you use a real device there is also the side benefit that the test runs faster than on the emulator.
You're looking for Robolectric.
Robolectric is a unit test framework that de-fangs the Android SDK jar so you can test-drive the development of your Android app. Tests run inside the JVM on your workstation in seconds.
It is not complete yet (e.g. Support Library Action Bar is not supported) but it will save you a lot of time anyway. Besides you can add what's missing by developing shadows yourself.
My alternative looks like this:
I have refactored my android app into
app (gui using the libs),
android-independant-lib (service-interfaces, dto-s, businesslogic without database bindings)
android-dependent-lib (android specific implementation of the of the service-interfaces and database binding)
for the android-independant-lib i have created "normal" junit-tests
for the android-specific parts i currently have no automatted tests.

Automating automated testsing

What I mean is automating test writing itself. Tester can perform some actions, they get recorded, and then can be used as a base for writing tests. I wasn't able to find any existing solutions, is it that hard to implement? Or did I miss something?
I mean it might be as simple as logging all touch/key events, and write tests using for example https://github.com/square/javawriter
UPD: I should've mentioned that I know of standard testing approaches:
UiAutomator
Roboelectric
Espresso (android-test-kit)
But that wasn't what I meant. Writing tests by hand is a pain, and I wander if this process can be simplified.
UPD1: If anyone stumbles apon this question, this is what I meant. It's non-free, so I'd gladly check out free/opensource analog.
You can try to use Appium (iOS/Android) which is free and has a feature that lets you record actions, and run them through. However this only works for UI functionality and any standard Unit tests will still need to be developed the standard way (manually). As a note, Appium is new (~1 year old) so there may still be bugs (such as not running in iOS devices with Xcode 5.0.1 +)
appium.io
I feel it's worthwhile to mention that appium doesn't require any modifications/additions to your android/iOS projects like a few of the other solutions I have found.
Please Calash https://github.com/calabash which is open and compatible with both iOS and Android.

Is there any frameworks for integration testing of Android apps which can drive emulator/device beyond one app

I found couple of difference frameworks which can test Android apps, but all of them are limited on testing of just one app (because mainly they use Instrumentation)
My app contains a service which could be called by other apps and I want to automate testing of this too. So, I would like to be able to write some tests which automate UI in other apps.
Have you seen anything, except MonkeyRunner? I looked at it, but the API is quite poor.
Take a look at Sikuli IDE it's easy enough to use and is based on Python.
You can bascially run integration tests using it, (kind of like Selenium for desktops).
There is also Selenium Android Driver if you want to run automaton tests from the Android WebView!
You are right, a bare monkeyrunner is perhaps not enough, but if you combine it with other tools perhaps you can find your way. For example, AndroidViewClient is a library that adds the ability of:
finding Views by ID, very much like you normally do in your Android Activity (using ViewClient.findViewById())
obtaining the value for almost any of the Views properties (using for example View.isChecked() or View.mText())
sending touch events to the Views by simply invoking View.touch()
More details an a complete example can be found at http://dtmilano.blogspot.com/2012/02/monkeyrunner-interacting-with-views.html

VS and MonoDevelop code sharing

Knocking my head against the wall trying to figure out a good workflow for sharing code between a few WP7, iOS, and Android applications, all implemented in .NET/Mono. Anyone has figured this out?
I have some experiments in code sharing that you can see here: http://granite.codeplex.com/
What I've learned so far:
Pure business objects are your best friend. Pushg as much logic as possible into these.
Testing frameworks on mobile devices are just about useless, but you can unit test the heck out of your business objects using the desktop platforms (.NET or Mono).
Mono has more bugs that .NET, so make sure you run your unit tests against it.
Make sure you use a source control that works with MonoDevelop. That means no TFS.
Make sure you use a Unit Test framework that Mono supports. (e.g. NUnit)
View-models can be shared with the right abstraction layer, but it may not be worth it.
I use SVN in order to code in Mono on PC/MAC/LINUX - tho i rarely do anything on Linux other than POC's.
As far as workflow for sharing libraries between all of these different systems - good luck. All i can offer is:
- Be sure to unit test as Jonathan pointed out
- Know all of your compiler hints that are available
- Avoid P/Invoke or any O/S specific calls if possible
- Pray
Good luck :-)

Categories

Resources