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; otherwise, 'mach geckoview-junit' will offer to install it.

mozilla-central$ mach install --app 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>

Please note that unlike Robocop tests, <class> needs to be specified using the fully qualified class name including the package, e.g. org.mozilla.geckoview.test.ContentDelegateTest.

To run just one test:

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

To run more than one test:

mozilla-central$ mach geckoview-junit <class1>#<test1> <class2>#<test2>

mach geckoview-junit also supports running a list of tests that are specified in a text file. Each test must be listed on its own line. For example:

<class1>#<test1>
<class2>
<class3>#<test2>
<class3>#<test3>

To run the tests specified in the file:

mozilla-central$ mach geckoview-junit --test-filters-file <path-to-filter-file> 

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:

import org.junit.Ignore
...

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

Tests can also be conditionally skipped using JUnit's assume or assumeThat methods. For example:

import org.junit.Assume.assumeThat
...

@Test fun contentCrashIgnored() {
        // Cannot test x86 debug builds due to Gecko's "ah_crap_handler"
        // that waits for debugger to attach during a SIGSEGV.
        assumeThat(sessionRule.env.isDebugBuild && sessionRule.env.cpuArch == "x86",
                   equalTo(false))

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-x86_64 -u geckoview-junit --artifact

Currently, geckoview-junit is only run on android-x86_64.

Contact information

geckoview-junit tests are maintained by :snorp and :gbrown. Bugs should be filed in Geckoview :: General.