Using Eclipse to test intents in android - java

I have recently created an Android application that allows users to add shopping items and lists to a database and need to test its functionality. I have found information on testing whether certain TextViews contain the correct strings etc but that's about it.
I need to have a test project that actually adds food items and tests whether that was successful, I was thinking maybe:
Moving to the desired Activity
Filling out and submitting the form to add a shopping item
Move to the Activity containing all food items and their details
Check the item was added correctly
Is this possible to do using an Android test project in Eclipse? If not, are there any other useful tools available for this kind of testing?

Also, see android.testing.ActivityInstrumentationTestCase2<>. You can set up an Intent to be given to the activity under test using setActivityIntent(), then do getActivity() to start the activity under test. There are tutorials in the Developers Guide for learning how to use ActivityInstrumentationTestCase2.
Unfortunately, there doesn't seem to be much documentation for setActivityIntent(), and my guess is that it doesn't test intent filtering.
I think you should do it as unit tests. First ensure that your source Activity is issuing the correct intents by writing a test destination that simply logs all the incoming Intent data.
Then write unit tests for the destination, based on setActivityIntent(). You can also use
Robotium or MonkeyRunner (part of Android).

You cam use adb shell am to open a activity or send broadcast.
For example. You want to open a activity, the component of it is "com.test/.MainActivity". then you just need to type "adb shell -n com.test/.MainActivity".

I have asked around and a friend of mine told me a list of tools you can use to functionally test android application.
Freeware:
FoneMonkey
Robotium
Commercial products:
SeeTest
uTest
Perfecto Mobile
Test Center Enterprise Automation (Keynote Device Anywhere)
He recommended FoneMonkey as good enough tool for functional testing. I don't think you can implement functional tests for Android Application using only Android library testing tools without any third party extensions.

If you like to test your database, you can open File Explorer of ADT, save your database to other place and open by other database reader. (such as: SQLite Database Browser)

Related

Is it possible to automate NFC payment tests for Android?

I'm testing an app that supports NFC payments, however I was unable to find any solutions on automating these tests.
I'm using Appium as my open-source automation tool.
Fully automate NFC payments with desired variables.
It's not supported by appium neither any other framework. However, I have a solution for you. Have your app's developers add a menu for you with several choices, each choice represents a payment scenario from your design. Once you click on each one of them, it will mock the real NFC action. Make sure that this menu is only in debug mode and not in release mode.

Do I need to automate an app that Scan a QR, Is there an Appium function to send a specific QR from JAVA?

I have an app that scan a QR code.
Scenario:
1 Go to the app
2 Click on Scan button
3 Open The camera to scan a QR code
My question is, Can I "Emulate" the QR with appium?
In case you have a
QR code. Scenario
that needs to make sure that the end to end functioning of software is working fine, or specific business process flow of the software is working fine - I would say, that this should be covered. Maybe, the correct question is, does this need to be automated?
I have done similar automated checks in JS, so I can only give you some design ideas. My scenario was involving a Barcode scanning in the middle of the test, so the way to achieve this without actual device, for me was to use broadcast. Sample code bellow:
adb shell am broadcast -a {your-app.action_scan} -c android.intent.category.DEFAULT --es com.symbol.datawedge.data_string {some-expected-string-as-barcode-value}
Note that this approach relies on testability, that is designed alongside the dev team. In my case, it was OK for them to allow and receive such event. It was tricky to sync the event and the test flow, but at the end we got good coverage of this major functional area.
Following you can do scan:
keep you phone on stand back side you can put the QR code whenever the camera open it will scan
If that app supports the pick the QR code from gallery, you can pick from QR code picture from gallery
Since Appium interacting with UI, it doesn't have access internal components.
Appium espresso might have the internal components like set drawable image and it comes with certain limitation

How to Handle Third Party's Web View in Test Scripts witten in Robotium

I am using robotium tool for wirting the test scripts for an application . I wanna know how do I handle the third party's webview(i.e, Login) in my application .
For example, if I have a button Checkout With Paypal and when I click on it i get a login page from Paypal third party, which asks for the following
Login ID:
Password:
Then how do click on the above to text boxes in the test script and enter the appropriate text in that.?
If the webview is external to your application then im afraid to tell you that when using robotium it will be impossible to test what you want. Robotium can only inject events into your applications process which this will sadly not be a part of.
If however it is within your application then you are (slightly) in luck. You can interac with the webview, however robotium currently does not have any way to interact with elements inside webviews. It is possible to do this though, you have to fire in javascript yourself to interact with the web page. This is a bit of a pain but products such as https://github.com/calabash/calabash-android do it nicely so you can look at their implementation.
There is a third option, get the developers to fake the section of the application for your tests. Then add in a test that runs on a version without the faking to check that the correct intent is fired using an intent filter, that should cover both bases.

How do "add-ons" work for native apps?

I am designing an app for Android, iPhone/iPad and Windows Phone using GWT and PhoneGap. GWT will allow me to write the entire app in Java (my strong suit, unlike JavaScript or CSS) and will translate it into cross-browser JavaScript/AJAX. PhoneGap will then wrap that resultant JavaScript and turn it into a native app for each of the three platforms mentioned above.
I would like to have a "plugin-oriented architecture", whereby users can optionally purchase (or qualify for through other means) "add-ons" (plugins/extensions) that will enhance the functionality of the app.
Normally I would accomplish this by using the Java Simple Plugin Framework (JSPF) and allow users to download plugin JARs as they paid for them. These plugin JARs would then be added to the classpath of the main app so that the next time it starts and scans the classpath for plugins, it finds them and loads them.
Is this possible with native apps? I don't believe I can deploy anything other than APK, IPA and XAP (Android, iPhone and WinPhone respectively) files to these marketplaces.
In Java-land, this would be like having to download a "base" app in the form of an executable JAR (containing its own main method), and then having to download a "plugin" app that is also an exectuable JAR, and somehow get the two to behave like a normal plugin architecture (which would be if you have 1 exectuable JAR base app and then 1+ plugin non-executable JAR libs).
So I ask: how do add-ons work for native apps from a deployment/download perspective? How do you get 2 or more APKs/IPAs/XAPs to communicate with each other on the client-side? If not possible, how do native app developers handle add-ons (I know they exist, I've seen them!)? Thanks in advance!
as for iPhone - the only way is to implement the additional features and have them disabled until the user purchases in app to unlock the feature.
In Android you can have apps communicate with each other so that the user can just load add-on apps that provide only the add-on functionality. For more detail on this.. android communication between two applications
WP8 - I do not yet have experience
Although I am not a core Android Developer, here are some suggestions from my experience with Android till now:
One possible solution for Android is to use Updates for application. One way to achieve this is using a Background Service which checks for updates whenever app starts or use GCM (Google Cloud Messaging) to push update messages to the app. Second option is much better as you can provide instant update to the user ,on per device basis (a user can have multiple devices), as soon as he/she has bought your add on feature. After the user has got the update message you can download the whole app with new feature and update app on the device. Of course in this case you need to backup the existing data of the app and restore after installation of updated app.
I don't know if this thing can be done but it would be also be an good option in my opinion if you can provide a legitimate user, who have bought the particular add on, an updated app through Android Market.
Another way is to create each add on as a Service and then let the main app can detect (or bind) those services at startup and if they are available, your app can communicate with them easily. You can even call the UI portion of the newly deployed add on from your main app by using Intents and BroadcastReceivers.
You may also find this useful as far as Android is concerned:
However, there are ways for an application to share data with other
applications and for an application to access system services:
It's possible to arrange for two applications to share the same Linux
user ID, in which case they are able to access each other's files. To
conserve system resources, applications with the same user ID can also
arrange to run in the same Linux process and share the same VM (the
applications must also be signed with the same certificate).
Hope this gives some useful information to you.

How can I load an apk dependency from the android market?

I'm using google moderator as a simple way to collect feedback for my application. There's a google moderator app on the market that provides a better interface than the website for mobile users.
Getting to the point: Is there a way to get it to install along with your application or a reasonable way to identify if another package is available so I can direct users to the market to download it?
Is there a way to get it to install
along with your application
Not automatically, no.
a reasonable way to identify if
another package is available
Use PackageManager. Create the Intent you would use to start the third-party activity and use queryIntentActivities() on PackageManager. If you get an empty list back, nothing is installed that will respond to your Intent.

Categories