Create Android APK Test Application - android

I have an app to be tested, called app A.
I also have a test project for automated testing of this app.
I want to have a second app which includes these test cases, so that I can run all test cases for app A by starting another, app B.
I don't want to start tests in Eclipse, I want to start them directly from the phone where the app should be tested
Someone knows a solution?
BR

I guess you want to run the tests from your code, in such case this post, presenting a solution to run instrumentation from code, will be of help.

Maybe i didnt' understand... You want to start an activity from MainActivity but the 2nd activity has to be hidden from launcher?

Related

How do you write an Androidx Instrumentation that runs multiple Instrumentations?

I want to write an Androidx test that starts an Application, waits for it to crash, and then starts it again.
As I understand it, by default, AndroidX tests run on a instrumentation, and when one test crashes, the entire instrumentation is brought down with it.To prevent one test from crashing the whole test suite, AndroidX includes an AndroidTestOrchestrator. This allows each test to run in its own instrumentation, so one test crashing only brings down the instrumentation it is in.
Given what I am trying to do, it looks like I will need to create my own AndroidTestOrchestrator to run a test with two instrumentations, one to run the Application crash, and then another to see that it is recovered from correctly.
How feasible is this?

Running Espresso test on a specific Android application from outside that application

I would like to write an Espresso test that I can run on an application from outside that application. I don't have much experience with Android, but, as I understand it, a UI test is generally written and executed from inside the project of the application that it is supposed to test. For instance, according to the file explorer in Android Studio, the java files for a test application I was developing are stored in com.package.example.name, and the java files for the UI test are stored in com.package.example.name (androidTest).
I want to develop a UI test for an application (Application A) for which I do not have the project files. As I do not have the project for Application A, I cannot develop the test for Application A from inside that same project like I normally would. Thus, I have to somehow create and run it from outside.
My initial thought was to create a test application (Application B) from scratch and add a button to it that, when pressed, will open Application A. I would develop an Espresso test from inside Application B, have it press that button to launch Application A, and then have it follow other Espresso instructions I would develop by viewing the R.ids of Application A's UI elements through uiautomatorviewer.bat, included in the Android SDK tools.
At least to me, this seemed like it would work just fine in theory, so I went forward with the plan. However, when the button inside Application B is pressed by the UI test and Application A launches, the test cannot find an activity to continue testing on. No error is explicitly thrown; Logcat prints messages like "W/RootViewPicker﹕ No activity currently resumed - waiting: 2000ms for one to appear," repeatedly, where 2000ms increases as time goes on.
Historically, I have not had any problems when running Espresso tests across activity changes. I assume this issue has something to do with the fact that the activity being launched exists outside of the project where the Espresso test is based.
If anyone knows of a way to get an Espresso test to run successfully on an application when based in a project located outside of that application, I'd appreciate any advice you may be able to offer. I think I'm on the right track, but I don't know for sure. Thanks!

Robotium Home Button and resuming to app

I'm new to Robotium testing and I want to test the following scenario:
1.) Start the app do something.
2.) Press the Home Button.(Close the app)
3.) Resume the app and test if everything is ok.
My question is how can I achieve steps 2 & 3 ?
You can't do this with robotium, neither with pure Android Instrumentation framework. You should rather take a look on UIAutomator, if you have to test such scenarios.

Android APK problem

while i compile my application on sdk and on my phone i see the same application 3 times over the phone. Only 1 of them works and the other 2 throws exeption. this is the printscreen of the problem.
That sounds very much like you've marked all the activities in your application with categor android.intent.category.LAUNCHER --- that's what makes the activities show up in the launcher. Naturally, if one of your activities gets launched when it's not expecting to be, it'll likely crash. But you'll have to post more info (like a stack trace) to tell for sure.
When working on an emulator, you can choose to wipe all user data on boot from the AVD manager. You might want to give that a try.
Also, as Kartik said, if you changed the package name of the application, it will install alongside the previous versions as Android sees it as a new application and not as an upgrade.

how do I run Android test project from another android application

I created an Android test project using instrumentation and it works find with eclipse running as Android Junit test. It also generated apk file.
My question is how do I run this test from another android application instead of from eclipse. For example, if the test project is named T and I have another Android application named A. Then I would like to open up T from A.
Thanks in advance..
I think it will be good if you try to call the appropriate intent on a button click or on whatever you want to start the program. For example:
startActivity(new Intent("com.yourprogram.T") I'm not sure but i think it will works.
Why do you need to open Test project from an app on Device. I dont think you can do it because Android does not allow any app to inject action or call functions from other apps.

Categories

Resources