Ganesh
Ganesh

Reputation: 934

How to write test cases for the home screen activity using Robotium in Android

I am working on Robotium to write the test cases for one of the Android application. My requirement is to write the test suits for the lock screen and home screen with my test case. But I am unable to get home screen events and lock screen dragging through my instrumentation test case.

Upvotes: 3

Views: 2884

Answers (3)

piotrek1543
piotrek1543

Reputation: 19351

Limitation of Robotium and Espresso

Robotium as Espresso are typical UI testing frameworks with one big limitation - using them you are allowed to operate only inside your application under test context.

It means that they won't check some kinds of dialogs, messeges popups, notifications or lock screen.

Selenium, Appium, Calabash (according to thienkhoi tran answer)

Selenium is another test framework, which has its own implementation on Android called Selendroid. If you want to keep only one test framework Selendroid as well Calabash (open-source test framework based on Cucumber with big support from Xamarin guys) and Appium (another great tool with Testdroid maintenance) would be great choices.

I have no experience with these frameworks, but I'm pretty sure that at least Apium can perform tests on home screen activity, but its syntaxt is not easy to learn and readable as Calabash or Robotium.

Solution: Robotium with uiautomator

Finally, we decided to keep Robotium tests and just add another framework to do it. Espresso as I said won't do it, but Google with Android Testing Support release another instrumentation framework called uiautomator, which works perfectly with Espresso, but also with Robotium.

Check: https://github.com/codepath/android_guides/wiki/UI-Testing-with-Robotium#robotium-in-googles-espresso-way (to change config of Robotium to Espresso-look-a-like)

Official uiautomator site: https://google.github.io/android-testing-support-library/docs/uiautomator/

How to mix Eespresso with uiautomator(works actually also with Robotium): http://qathread.blogspot.com/2015/05/espresso-uiautomator-perfect-tandem.html

Tutorial: https://software.intel.com/en-us/android/articles/automatic-android-testing-with-uiautomator

Hope it will help

Upvotes: 0

thienkhoi tran
thienkhoi tran

Reputation: 341

If you want to test an application with selenium, or you have to have source code or you have to have an application, which has the sign same as testing project to run. Normally, people use keystore debug to sign both of them then test them.
Base on that rule, you want to test Launcher, you have to have a root phone -> download a launcher app and re-sign -> replace new launcher app to current launcher app in rooted phone.
So it is so complex.
Beside, you can create test case with Device manager to interact to device hardware such as lock, unlock, turn on wifi, GPS...

Upvotes: 0

avh4
avh4

Reputation: 2655

The lock screen is not a normal application, so you won't be able to instrument it (which means you can't test it using robotium).

The home screen is part of the Launcher app, and you should be able to instrument it and test it as you would with any other app using robotium.

Upvotes: 1

Related Questions