Geckoview-Junit Tests

The geckoview-junit tests are on-device Android junit tests written for geckoview.

By default, tests are from org.mozilla.geckoview.test.

These tests run on an Android device, controlled by a host (typically Linux) using mozdevice (adb). In automation, tests normally run in an Android emulator.

Running tests locally

If desired, connect an Android device to your computer, or start an emulator, and make sure your device is visible to adb:

$ adb devices
List of devices attached
emulator-5554    device

If no device is found, 'mach geckoview-junit' will offer to start an emulator.

Before running tests, install the androidTest apk on your device.

mozilla-central$ mach android archive-geckoview
...
mozilla-central$ find ~/objdirs/droid -name '*androidTest.apk'
~/objdirs/droid/gradle/build/mobile/android/geckoview/outputs/apk/androidTest/officialWithGeckoBinariesNoMinApi/debug/geckoview-official-withGeckoBinaries-noMinApi-debug-androidTest.apk
~/objdirs/droid/gradle/build/mobile/android/geckoview_example/outputs/apk/androidTest/officialWithGeckoBinariesNoMinApi/debug/geckoview_example-official-withGeckoBinaries-noMinApi-debug-androidTest.apk

mozilla-central$ adb install ~/objdirs/droid/gradle/build/mobile/android/geckoview/outputs/apk/androidTest/officialWithGeckoBinariesNoMinApi/debug/geckoview-official-withGeckoBinaries-noMinApi-debug-androidTest.apk
~/objdirs/droid/gradle/build/mobile/android/geckoview...oidTest.apk: 1 file pushed. 33.7 MB/s (40297116 bytes in 1.139s)
    pkg: /data/local/tmp/geckoview-official-withGeckoBinaries-noMinApi-debug-androidTest.apk
Success

mozilla-central$ adb shell pm list packages org.mozilla.
package:org.mozilla.geckoview.test

To run all tests:

mozilla-central$ mach geckoview-junit

To run just one class of tests:

mozilla-central$ mach geckoview-junit <class>

To run just one test:

mozilla-central$ mach geckoview-junit <class>#<test>

Disabling one failing test

There is no manifest listing the geckoview junit tests. To disable a single test, edit the source code and insert JUnit's @Ignore annotation before the existing @Test annotation. For example:

...

@RunWith(TestRunner.class)
public class TestSomeThings {
    @Ignore
    @Test
    public void testSomething() {
...

Running tests on try

To run these tests on try, use something like:

mach try fuzzy -q geckoview-junit --artifact

or

mach try -b do -p android-api-16 -u geckoview-junit --artifact

Currently, geckoview-junit is only run on android-api-16.

Contact information

geckoview-junit tests are maintained by :snorp and :gbrown. Bugs should be filed in Firefox for Android :: Testing.

Document Tags and Contributors

 Contributors to this page: gbrown
 Last updated by: gbrown,