I am trying to automate test cases using robotium. The problem that I am facing is that my app has, like all apps, lots of activities. So I dont want to test the whole application again and again, but only specific activity. How can I do this.
I cheat - I add a simple activity with buttons that can launch any other activity, with sample parameters, where needed. I then use Robotium to launch a specific activity and test it, rather than the full application. Once this is done though, I pretty much follow http://developer.android.com/tools/testing/activity_test.html to make sure I do proper, full-cover testing for my application.
The last step is to remove this dummy "menu" activity from the application.
in constructor of robotium test we write super("com.example.helloworld1",MainActivity.class); where instead of MainActiviry.class we can write OwnActivity.class. Here OwnActivity is the activity from where we want to start testing our application.
Related
I am taking first steps in testing in Espresso. I can find a lot of tutorials telling me how to test one, single activity with Espresso. I have never seen any tutorial - how to prepare Espresso test for whole application.
I have whole app with like 10 activities which are having of course different ways to each other.
Is there any option to test whole app navigation with Espresso?
How to test single Activites which are "inside" the app? Sometimes they need some connection with backend from user which is logged into his account. I have to always log to test account or "mock" data for it?
If I am testing one app I have to always change "launcher" activity in Manifest or there is any other option for that?
If it is newbie questions and there is any article which can provide me that information, please share it with me.
Thanks!
Once Espresso launches your main activity, then you can basically navigate to any part of the app and you do not have to worry about launching different activities. As long as you can find the elements with which you have to interact with to navigate to different parts of the app and know of the appropriate strategy (by Id, text etc.) to interact with those elements, then you can do your necessary navigation in your app.
I do not know if you got the answer to your question.
If not, take a look at Android Testing Code Lab.
https://codelabs.developers.google.com/codelabs/android-testing
I think it has all the answers to yours questions.
If you to need more help tell us here.
I am writing a JUnit test for an Android application. I'd like to take snapshots of the application under test programmatically through the JUnit test. I've searched for days and it seems like my best shot is to follow How to programmatically take a screenshot in Android?.
The problem is I traverse the application under test by clicking buttons, etc. and by doing so I bring up different activities in the application under test. I can use getActivity to get and render the starting activity, but how can I get the activity instances that come up by clicking buttons, etc.?
P.S. ActivityManager.RunningTaskInfo does not do since it only gives me the activity names and not their instances.
Also, I don't want to manipulate the application under test in anyway.
Here's a good library for capturing screen-shots during tests:
https://github.com/rtyley/android-screenshot-lib
Just call poseForScreenshot() in your test code.
I want to start an app that is shown inside my app. At the moment I just start another app over mine with
Intent LaunchIntent = getPackageManager().getLaunchIntentForPackage(app.getAppID());
startActivity(LaunchIntent);
That works good, but I'd like to let the user know, my app is still in the background. With a colored frame for instance. I thought of loading the new app inside a fragment like with iframes in HTML but could not find a way.
Any help is appreciated.
This is not possible on Android, sorry.
Each app runs in its own process, and there is no way to run one inside another like an iframe.
I think you are confusing applications with activities.
You can run a shared activity in your application but not the entire application. So this would greatly depend on what you are trying to do.
Alright so I have an app that I would like to have utilize other apps. For example I have an app that does quite a number of things except for a directory look up since there is already an app that does that for my school. I know I can launch the application with intents, but that also brings them away from the navigation menu for my application. Is there anyway that I could run an app inside a view layout. I am not hopeful for this but I figured I would chance asking it anyway.
This is technically possible by using widgets. You can implement an AppWidgetHost, and other applications can create App Widgets to use inside your own app. This is how the launcher screen in Android works.
This, of course, will only work if other applications in question implement widgets. So, the general answer to your question would be no, it is not possible to host arbitrary applications or Views/Activities from other applications inside your own.
This not the Android design philosophy. You should send an Intent to the directory app, which I hope is designed to look up a result and then return it to you. The mechanism is startActivityForResult() in your app, and setResult() in the directory app.
I have an application that needs to launch calculator application in resized window on demand and then be able to close the calculator application using close button in my app.
How can this be done?
It cannot be done. You cannot embed other applications' code or UI in yours, outside of app widgets.
Also, bear in mind that LocalActivityManager is deprecated, and so you should be trying to phase out your use of this class over the next several months.