Are unit test cases provided for any app in AOSP(Android Open Source Project)in android? Suppose take Gallery App, which is a system app. If I download the AOSP, Is complete test suite available for Gallery App. I meant to say both unit tests and Instrumentation test suites?
From my experience in working with AOSP, there is a python script called runtest.py in platform development/testrunner/runtest.py to run every available unit tests on each module in AOSP. It is a good starting point to look for what you want, but beware some unit tests are outdated and obsoleted.
You can add tests and then be include into runtest.py to form a test suite. runtest.py will help you compile, deploy then run the unit test suite on the target device.
Related
I'm building my Android ap with Microsoft App Center.
Is there any way to run JUnit JVM unit tests in App Center?
At the moment App Center is running only the Android instrumented tests, this is, the tests that run on one emulator or real device (located in androidTest folder)
What I want to do is to run the tests that are pure Java/Kotlin and do not depend in the Android framework to work, the ones that run just on the JVM (located in test folder).
All I've found regarding tests in App Center is https://learn.microsoft.com/en-us/appcenter/build/build-test-integration.
Thanks
I contacted App Center and this is not supported yet. I created a feature request for this.
I'm working on an AOSP based distribution. And I'm trying to implement Local Unit Tests (not Instrumented or CTS), just plain local Unit Tests, using frameworks like jUnit, Mockito, Powermock, Hamcrest and if necessary Robolectic.
Currently, I'm able to build trough Android.mk an app like Launcher a simple Unit Test, and run it through CLI (Command Line Interface).
The problem is that when the unit test starts to get more complicated, I have issues with PowerMockito:
error: cannot access MemberModifier
import static org.powermock.api.mockito.PowerMockito.whenNew;
Anyway, my intention with this question is to know if anyone has some example of an AOSP project running with local Unit Tests.
I will want to run a functional tests on firebase on various devices. Does firebase support functional testing in android?
Their testlab has three types of tests:
Robo test
Instrumentation test
Gameloop
Robo test is ruled out as it is just a stress test and a load test like a money runner
When it comes to instrumentation test, first thing I want to be clear on whether it is a functional test written in expresso, UIautomator and ranorex?
If yes, I see that I have to upload two .apk's in there, one is AppApk and TestApk. I would like to know if AppApk is the application under test and TestApk is the apk that is created to test the application?
If yes, I found uiautomator tests are bundled inside the src folder and is a java file. I also found that, there is a python wrapper for uiautomator that can be coded to write tests for android.
Now there is kivy.org to bundle python file into an .apk since android studio does not support python.
Now, How do i run Android uiautomator tests in python? Is there a way, to run python scripts inside the android studio?
And How to run functional tests in firebase? Do they support?
I'm a fanboy of Test-pyramid application in software development and want the same to be applied in Mobile software development as well.
For this, I'm desiring to leverage both Appium (for functional tests) and Espresso (for Integration Tests), and have the following questions:
The structure of my tests in Android Studio with Gradle has only 2 folders: app/src/test and app/src/androidTest.
The former test is meant for writing Unit tests with JUnit. The later for functional tests; and I'm using espresso tests for integration-testing making use of the latter directory.
I know I can create a separate project for Appium and write functional tests. But prefer to have those as part of the project in separate test source directory, so that it can be run at different intervals in my CI pipeline. How do I go about doing this? Is it possible to create another source test directory like app/src/functionalTest? Pointers to sample projects in github or resources is well appreciated.
I have a Robolectric test project setup, but I'd like to also run these tests on my device to check that I don't get bit by JVM vs Dalvik implementation differences.
Unlike robolectric tests, I won't run these tests frequently. My concern is that there's little effort to maintain the test suite and that they verify actual device functionality.
What's the best way to do that?
What I've currently got:
My robolectric test project as a test case TestPackage. I created an Android Test project with a test case TestRoboOnAndroid. It creates a TestPackage and has a test for each test in TestPackage.
Right now, every time I add a test to my robolectric suite, I need to manually add it to my device suite. Is there some way to do that automatically with reflection?
Also, Robolectric uses JUnit 4 (by default) and Android uses JUnit 3. So I have to write all of my Robolectric tests using JUnit 3 style (importing from junit.framework instead of org.junit).
The whole point of Robolectric is NOT to run it on the device and the design is based on that. If you want to run something on the device look at the default instrumentation tests from the SDK or Robotium.
It is totally feasible to run your Robolectric tests on the JVM and in addition create Robotium tests that rely on device specific interaction (e.g. creating screenshots, hardware differences...) and run on devices and emulators all combined into one build.
The easiest way to do that is to use the Android Maven Plugin.
I use a tiered system, where I prefer earlier tiers where possible:
Pure unit tests. I try to make as much code as possible fully independent of Android APIs, and then use "pure" unit tests which can run on any JVM. These tests are the fastest, and it helps keep code that has no need to be Android-specific portable.
Robolectric-supported unit tests. Where my code has only small dependencies on Android APIs, that can be satisfied by Robolectric shadows, I test it with Robolectric. There is a little more setup time for Robolectric compared to pure tests, but it's still faster than starting/running on an emulator.
Android framework tests. Where Robolectric doesn't cut it - either because the shadows don't exist, or because I'm heavily using Android APIs (and therefore want to test against the Real Thing) - I write test that run on the emulator/device with the default framework.
The point of the tiers is to keep things as simple as possible, which keeps the full suite faster and helps promote cleaner code.
We use Robolectric for unit testing against the JVM and Calabash-Android for system testing against Dalvik. Both can be integrated into our Jenkins CI build and between the two tools I feel that we cover all the bases.