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.
Related
I have built a react-native application and am trying to build a few specific end-to-end tests on the android side. For this, I have setup detox. Unfortunately, to test properly, I need to see how the application responds when the user is performing actions outside of the target application.
e.g. I need to automate click A within target application A, click android home button, swipe right on screen and then open application B. Application A should then open itself and the test can confirm if it has opened to the right screen.
Is something like this possible within Detox? If not, are there any frameworks that would allow me to test this?
What you are wanting to do is use something called 'Appium' instead of 'Detox'. This is due to Appium interfacing with the androids uiAutomator API which allows automation and testing outside of a single application, Detox is more for testing the behaviour within the application itself rather than outside of it.
I am doing automation testing using Espresso but I struggle in Camera Capture... I have written code for camera that it will open, but it is not able to click. What I need is to click in automatically if it is possible.
Please give me any suggestions. Below is my code:
onView(withId(R.id.photo)).perform(click());
Things get tricky with Espresso when you are working with tests that include multiple Activities. I prefer to use UIAutomator for such parts of the test.
With UIAutomator, you can do something like:
UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
.findObject(new UiSelector()
.resourceId("com.example.package:id/photo")).click();
Remember that your IdlingResources won't have any effect on UIAutomator, so you might need to add extra delays to wait for that Activity to be created and initialized before it is clicked on.
Here is how to setup UIAutomator: UIAutomator Testing | Android Developers
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!
Where can I find an android app code with its robotium test code online?
I'm looking for something really simple that can just display written content when pressing a button or something.
You can download an app and example test project from here:
https://code.google.com/p/robotium/wiki/Getting_Started
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?