I'm final testing a project I've been working on. So far, I've tested the app by installing on various virtual & real devices, and user testing all possible outcomes of the functionality.
Going through the release preparation doc, android test project is the method used in the guide.
I've started to write out some test cases but I can't see the benefit, or additional options from using a test project, that I have not already covered in device/user testing.
Am i wrong to just stick with the device/user tests, or is the test project method just a coded version of the tests I've already completed?
The big advantage of unit-tests is that you can run them always after you did some changes in your code.
This way, it is a lot easier to find a bug which breaks already working functionality.
Related
My team is responsible for maintaining a C++ library built, amongst other targets, for Android using NDK. We have unit tests that are based on googletest/gtest and are built as simple executables. Our automated build system currently runs these tests on a physical device by running adb commands.
It has been suggested that we investigate using Android Device Farm, at least as an option - we occasionally get trouble with specific versions of Android, and it would allow us to test more widely. However the examples I am seeing reflect running proper Android apps via a generated apk - they would need an App entry point.
I am thinking this would need a dummy app to call the unit test code via an JNI entry point and then exit, or is that over complicating something that is better supported and I've not noticed.
Has anybody tried doing this?
While developing an app I more and more stumble upon the fact that I need to run interaction tests where two emulators are running the app to ensure the entire integration is working by testing the interaction between those (and not mock one of the devices)
During research on the topic (which is quite hard to search for because I do not want to run the same tests on multiple devices) I found a couple of solutions, however none of them seem to integrate very well into an Android Studio workflow. Some tools I've found:
UiAutomator
UI/Application Exerciser Monkey
Appmium
Some blend of adb, ruby, python etc.
Some projects on github
My expectation may be off but is there no framework or tool with a similar level of integration like running an instrumented tests that allows me to connect to several devices and perform interactions on them together?
Some of those approaches above require out-of-the-tool tinkering with adb or require a lot of environment to be set up.
Good answer to this question here:
https://stackoverflow.com/a/49647422/14338677
In short:
1.Create communication proxy that will be between sender and receiver
2.Add build type autoresponder, and communication proxy code get empty if (!BuildConfig.AUTORESPONDER)
3.Install autoresponder app to emulator or device when you will be testing
4.Run another test app with Espresso that can communicate with autoresponder app
5.Use Thread.sleep(...) to wait response of autoresponder app
I am currently testing an app for Android phones using the Espresso library with local devices as well as the Google Firebase Test Lab. For a good portion of these tests to be functional the phone running the test needs to connect to another phone or at least receive feedback from another device. I have been trying to do some research but really can't find anything on what I'm looking to do, seeing that it isn't a common practice.
Is there away to run Espresso or any small script directly on an Android device? I just need a script to sit idle or looping until it receives the information from the tested device, accepts it so the test can continue. I am not trying to alter any direct code in my app to auto accept things, I want to keep the app itself as untouched as possible. And I could manually do it on a small scale, but with Firebase I would like to test lots of devices at once or will run tests daily, sometimes when I'm not there for feedback. I want to automate this process as much as possible, so anything that could do that would help.
I've automated this process completely. The best thing is that you don't have to keep busy of your Android Studio and resources. Everything is done remotely.
You can use this plugin to setup Firebase test lab:
https://github.com/piotrmadry/firebase-test-lab-gradle-plugin
Hopefully you have CI (Continuous Integration) for your project.
So after your setup for test lab (you can define as many devices as you want)
You can create 2 parallel jobs on you CI:
First - it would build your project in normal way
Second - would run android task created by plugin ./gradlew uploadTestLab. After this job you will be able to look at results in Firebase Console.
In Android Studio 2.2 there is supposed to be a test recording function? Where do I find it and how do I use it?
Update june 9th:
It is now available with android studio 2.2 preview 3!
Espresso Test Recorder
Demo of the Espresso Test Recorder shown at IO is now included in Preview 3
Screenshot of my pc:
Download it here or patch directly from android studio preview 2.2
Update may 30:
Android Studio 2.2 preview 2 is out, but no 'Record Espresso Test' option yet.
Unfortunately the Espresso Test Recorder is still not in this build; we're addressing a few more issues and then hope to have it ready in the next build!
From the changelog.
Update:
It was not in the Advanced Espresso presentation as I expected, but in What's new in Android development tools (credit to flackery). They show where to find it:
It's also explained in the latest android-developers blog
Espresso Test Recorder: Sometimes writing UI tests can be tedious. With the Record Espresso UI tests feature, creating tests is now as easy as just using your app. 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. To use the recorder, go to the Run menu and select Record Espresso Test.
However there is no way to get that option in the current release, updating all (platform)tools etc won't make a difference either.
For now we can only assume that this was unintentionally left out, and will be included in the first next release.
The only sensible thing I could find about this is
Creating tests is now as easy as using your app. Run your app in debug mode and enable recording, and this feature will capture UI events and convert them into Espresso Tests that you can run locally or even in the Firebase Test lab.
From venturebeat
Running in debug is simple, but enabling recording.. I'm not sure what they mean by that. There is a recording option, but that is for capturing the screen and saving it to a mp4 file.
There is currently nothing to be found on the net, and nothing in android studio itself either, that explains this feature in more detail than "it's there".
There will however be a talk at Google I/O today, Advanced Espresso, where they will talk about this new feature and I expect it to be clearer after that.
I will update my answer once I've seen the presentation.
It's now live with Android Studio 2.2 Preview 3. Please send all feedback and issues here: https://code.google.com/p/android/issues/entry?template=Espresso%20Test%20Recorder%20Bug
As described in the Google I/O session 'What's new in Android development tools', we can access the 'Record Espresso Test' from the 'Run' menu.
Unfortunately this item is not available in Android Studio 2.2 Preview 1, and might be made available in a future release.
I've just reviewed about 10 Android books, read a bunch of articles and found a couple of frameworks, but still I haven't found any comprehensive way of testing Android applications.
It's too bad that testing appears (if at all) only as a single and short chapter only in some books.
There are:
ActivityUnitTestCase and ActivityInstrumentationTestCase2
Robolectric
Robotium
But none of them has sufficient documentation, tutorials or example. I couldn't able to setup Robotium with Gradle as well to be run either from AS or even command line.
What is the most current way to test Android applications with Android Studio 1.0 and Gradle 1.0.0? What frameworks and tools do you use? Where do you learn testing recipes for Android?
The only thing I managed to setup is standard android ways for testing applications, however there are only few examples how to do that.
The problem is that, there is no single page, that covers all Android test frameworks. Anyway there are more of them than you listed above.
Espresso
UIAutomator and related page
Calabash gh project and official page
Appium gh project and official page
Telerik
I don't know much about integrating them with Android Studio as it still is in infancy, however it should be feasible.
Check out Blundell's blog for some good tutorials: here's the one for espresso. Be warned, while I could get Espresso and JUnit tests to work, I haven't managed to get Robolectric to work yet. If anyone has a way to get it to work for projects targetting API 21, I would be keen to know how.