AndroidStudio record Espresso test - android

I'm trying the new AndroidStudio 2.2 "Record Espresso test" tool.
(Run -> Record Espresso test).
From what I understand this tool records every interaction and convert them to a single test file. What if I need multiple files, one for every activity I'm interacting with? Is this possible?
Is there a way to record only one target activity instead of go through the whole app every time?
Unfortunately there's no mention of this kind of feature in this android blogpost and maybe the feature is no there at all but I couldn't find any information about that.
The blog post just says:
Android Studio will capture all your UI interactions and convert them into a fully reusable Espresso Test that you can run locally or even on Firebase Test lab.

According to:
Android Studio will capture all your UI interactions and convert them
into a fully reusable Espresso Test that you can run locally or even
on Firebase Test lab.
Espresso Test Recorder although it's already added in Android Studio 2.2, it's still pretty experimental feature. Like you said in comment it allows you to record the app workflow, but you cannot record simple activity or fragment. Maybe in the nearest feature it would be added like Android TV support.
What if I need multiple files, one for every activity I'm interacting
with? Is this possible?
The best way would be record app workflow and split them to the classes. Very handful might be learning basics of Espresso code using these documentation: https://google.github.io/android-testing-support-library/docs/espresso/index.html
I think that at this time the best way to write complete UI tests is to learn how to code, recording may help you, but it won't as it pretty naive, do the whole job.
Hope it will help.

Related

Should I be using the test classes on Android Studio?

Should I be using the test classes on Android Studio for my small application?
What can unit testing tell me that I can't already see in logs when I run the App? Can you give an example of something I should test by writing testing code rather than just manually testing stuff on my device?
Well, by using for instance JUnit you can test for much more cases (especially edge cases since you are able to use dummy data for the tests).
You can also test much more efficient. Let's assume you've manually tested for 30 minutes. If you change some small detail you would essentially need to test for another 30 minutes to make sure that the change didn't influence the other components.
But let's say you are using UnitTesting. Well, after changing some small detail you just run the test again and the outcome should be the same.
If you plan to release the app I would definetly make use of the test classes.
Take a look at this article for more details: https://www.seguetech.com/why-mobile-application-testing-important/

Is it possible to test multiple apps with espresso test recorder?

Is it possible to record tests for multiple apps with espresso test recorder or do you need to write code manually for these tests with UiAutomator?
For background, see:
Google's doc on Espresso,
Google's doc on Espresso Test Reorder,
Google's doc on UI Automator, and
Alex Zhukovich's tutorial Android testing: Espresso & UIAutomator together about combining Espresso + UIAutomator to test multiple apps. (Also Alex's previous tutorials on Android unit testing, Mockito & Roboelectric, Espresso, and UIAutomator.)
The pair of tools should work to test an app's notifications, for instance.
But these docs don't discuss using the Espresso Test Recorder for multiple apps. The test recorder is in beta and still developing.
Suggestion: Try using Espresso Test Recorder to record actions and assertions within each app separately, then manually combine the two generated test programs.
Please report back on lessons learned!
Espresso uses current applications context, so it means that you cannot do things like checking sharingIntent, notifications or opening another app.
You can make tests for each of your aplications, then write bash/python script for running them together, but as you think you cannot test multiple apps using single record or 'manual' test case.
I think that UiAtomator can make a thing as this a pure instrumentation testing framework, but I haven't used that yet.
Hope it will help.

Is there any frameworks for integration testing of Android apps which can drive emulator/device beyond one app

I found couple of difference frameworks which can test Android apps, but all of them are limited on testing of just one app (because mainly they use Instrumentation)
My app contains a service which could be called by other apps and I want to automate testing of this too. So, I would like to be able to write some tests which automate UI in other apps.
Have you seen anything, except MonkeyRunner? I looked at it, but the API is quite poor.
Take a look at Sikuli IDE it's easy enough to use and is based on Python.
You can bascially run integration tests using it, (kind of like Selenium for desktops).
There is also Selenium Android Driver if you want to run automaton tests from the Android WebView!
You are right, a bare monkeyrunner is perhaps not enough, but if you combine it with other tools perhaps you can find your way. For example, AndroidViewClient is a library that adds the ability of:
finding Views by ID, very much like you normally do in your Android Activity (using ViewClient.findViewById())
obtaining the value for almost any of the Views properties (using for example View.isChecked() or View.mText())
sending touch events to the Views by simply invoking View.touch()
More details an a complete example can be found at http://dtmilano.blogspot.com/2012/02/monkeyrunner-interacting-with-views.html

What is the best and easy tool to unit test Android apps?

I have been developing Android application for a small company and during the development process we need to do repetitive testing of some modules, So i searched tools for doing automation testing (unit testing) of the app. Android has a unit test tool however to write those test cases will itself take more time then to actually test it by hand.
I found some apps which do some great stuff and provide good charts for example Robolectric, robotium, fonemonkey4android, but am confused to what to be used, any one with any experience with the same can help.
I checked for previous questions on the similar terms like below
https://stackoverflow.com/questions/522312/best-practices-for-unit-testing-android-apps
But all the threads are very old and not so informative to decide on which to choose..
I think first you need figure out which part of your code you want to test.
For codes which doesn't related to user interface, you can test them with Robolectric. With Robolectric, the unit test code is the same to those written for java application. But it's not suitable for test ui components.
If you want to test ui, then you can choose robotium. But i always doubt whether it's worth writing tests for ui, they change too often..

Android, how to get information on which activity is currently showing (in foregorund)?

I wonder if there is a way to get information on which activity currently has focus (is in the foreground)? I am using instrumentation and I would like to know which activity is currently running in the application that I am testing against.
Thanks
Take a look at Robotium
'a open-source test framework created to make automatic black-box testing of Android applications significantly faster and easier than what is possible with Android instrumentation tests out-of-the-box.'
Homepage:
http://www.robotium.org/
Source:
http://github.com/jayway/robotium
Please note that the Robotium project is maintained by the company I work for

Categories

Resources