Espresso - Using google espresso how to send email from Gmail app - android

Using google espresso I am trying to send emails using Gmail app.
In Gmail app how to access resource id for Send button: com.google.android.id/send

nowadays it's impossible. Check my answer on similar issue: Espresso test for Notification to showing up
Espresso UI test framework doesn't see more than actual View. I doubt
seriously that you can check any notification with Espresso.
For this purpose use another Googles testing framework uiautomator,
which is described as:
UI Automator is a UI testing framework suitable for cross-app functional UI testing across system and installed apps.
Here you would find how to use it with Espresso:
http://qathread.blogspot.com/2015/05/espresso-uiautomator-perfect-tandem.html
More information:
Documentation(I): https://google.github.io/android-testing-support-library/docs/uiautomator/index.html
Documentation(II): http://developer.android.com/intl/es/training/testing/ui-testing/uiautomator-testing.html
Visit also:
Android Testing: UIAutomator vs Espresso
As syou would see the best way to do it is using both of Espresso and uiautomator testing frameworks.

Related

Device farm interactive testing done programmatically

AWS has a 'remote-desktopy' feature (https://aws.amazon.com/blogs/aws/aws-device-farm-update-remote-access-to-devices-for-interactive-testing/) as part of its device farm, but it is far too slow to use in browser. Does anyone know if there is a programmatic/CLI way to interact with that system?
I would like to test the functionality of a third party app on a cloud based mobile testing platform such as Firebase Test Lab, or AWS device farm. I have no way to instrument this app.
The testing requires I download two apps on the device (one is the app to be tested, the second has a supporting function). At the start of the test I have to launch the support app, and then switch over to the app I am testing. I imagine the only way to do this is via the device's 'home' button. The actual testing is just a set of basic UI interactions.
Does the Firebase Test lab or other platform have a feature that I could use to do this?
If there was a way to extract events from the AWS remote-desktop, I could see an approach using a selenium/other webdriver. But I am not sure this a real option.
Any thoughts on this are appreciated.
Thanks!
"The UI Automator APIs allow you to write robust tests without needing to know about the implementation details of the app that you are targeting. You can use these APIs to capture and manipulate UI components across multiple apps" (documentation)
To tap the Home button you can use UiDevice.pressHome().

Automation of Android APK with UI Automator

I want to automate an Android app using Google firebase test lab. I came to know that there are 2 tools with which we can do this.
Espresso & UI Automator: To use Espresso we need the App source code, but while reading some articles I came to know that we doesn't need App source code for UI Automator. I have even tried to use app source code of an hybrid app and found that there is only one element for App and not able to proceed.
Can someone help me how to automate an android app using UI Automator without app source code. I have my apk with me and not able to find any solution to run automation scripts using it.
The only way to automate android APK without source code is to use Selenium WebDriver, Appium or some similar framework, especially when it is not a native application.
For native applications, I strongly suggest to use Espresso.

How can I test integration between apps on mobile?

I am using Robotium to do the UI tests on my app, but I would like to test the integration between this app and other apps that we developed. I found about UIAutomator, but I would like to know if there is another solution to test this integration using Robotium or another framework. I don't want to mock the apps.

Android black-box testing (no access to app code). Is Google's Espresso a good choice?

I have recently been looking in to Espresso, which looks for me very promising.
I am recently working in an Android test project, and we are recently using Espresso as we see some benefits with that. Unfortunately the setup in the company I work for is such that I do not have access to the entire code for the Application we are testing.
So how I can create a test using android studio?
You can use UIAutomator to get the ids of various views.
See here
With view ids you can perform assertions/click and other actions on them
An example
onView(withId(R.id.play_search_container)).perform(click());
Hence you can go through the whole UI flow by clicking on various elements.
if you want to write a test outside of application's code, I mean: pure black-boxing, Espresso would be a pretty hard to implement as it needs a bit of application architecture (the same thing is with Robotium or `UiAutomator): names of Activities, views texts, contentDescriptions or idies.
You can use instead of Espresso:
UI/Application Exerciser Monkey
The Monkey is a program that runs on your emulator or device and
generates pseudo-random streams of user events such as clicks,
touches, or gestures, as well as a number of system-level events. You
can use the Monkey to stress-test applications that you are
developing, in a random yet repeatable manner.
monkeyrunner(requires Python language programming basics)
The monkeyrunner tool provides an API for writing programs that
control an Android device or emulator from outside of Android code.
With monkeyrunner, you can write a Python program that installs an
Android application or test package, runs it, sends keystrokes to it,
takes screenshots of its user interface, and stores screenshots on the
workstation.
The monkeyrunner tool is primarily designed to test
applications and devices at the functional/framework level and for
running unit test suites, but you are free to use it for other
purposes.
Calabash
Calabash is a framework that enables Automated UI Acceptance Tests
written in Cucumber to be run on iOS and Android applications.
Calabash works by enabling automatic UI interactions within an
application such as pressing buttons, entering text, validating
responses, etc.
From: Introduction to
Calabash
Hope it will help

Best practices for Android Unit Testing?

I am developing a mobile android app. What are the most common libraries/frameworks used for Android unit testing? I feel that most of the business logic, database testing, Web services testing can all be done using JUnit.
However, what's the best approach for testing UI, the UI workflow, etc? For example, how can we test if the Android app launches a web browser successfully? Or how can we confirm if buttons, certain things are pressed successfully? Or if images are loaded successfully?
I use JUnit for unit testing and Robolectric for instrumentation tests.
This article shows you a Hello World example with Robolectric
In recent times, I have been researching about integration testing in Android using Arquillian Droidium.
If you want to test some code that consumes a REST API, you can mock it with WireMock. With this library, you can mock REST APIs by code or even deploy a mock HTTP server in your own machine and set up your own mocked mappings.
For REST API mocks, I also recommend you to use Mockable.io.
2017 answer
The Android documentation has a topical series called Best Practices for Testing. I would start there.
Local Unit Tests and Instrumented Tests are set up by default when you start a new project. The general advice given is to use the local unit tests whenever possible. Sometimes this requires mocking an object that uses the Android API. The documentation recommends using Mockito in these cases. When UI tests (instrumented tests) need to be done, Android provides the Espresso framework. There are also other tools available, like the Exerciser Monkey (for stress testing) and UI Automator (for testing multiple app interaction).
Example
See this answer for how to get started with tests in Android Studio.
There is a guide for automated user interface testing on the Android Developers Website. I haven't tried it but it looks like what you've been looking for.

Categories

Resources