• Stars
    star
    169
  • Rank 224,453 (Top 5 %)
  • Language
    Kotlin
  • License
    Apache License 2.0
  • Created about 5 years ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Android Test Runner

Gordon

Latest release

Gordon is an Android instrumentation test runner designed for speed, simplicity, and reliability. We built it because neither Spoon nor Fork were fast enough nor reliable enough for us, and in attempts to fork those libraries we found them to be too old and complicated to be worth modifying. So we wrote Gordon from the ground up, using modern Gradle functionality and Kotlin coroutines.

Key features

See also:

Better Android Instrumentation Testing with Gordon on ProAndroidDev

Setup

With Gradle plugins block

settings.gradle.kts of your root project

pluginManagement {
    repositories {
        gradlePluginPortal()
        google()
        mavenCentral()
    }

    plugins {
        id("com.banno.gordon") version "$gordonVersion"
    }
}

build.gradle.kts of any modules for which you want to run tests using Gordon

plugins {
    id("com.banno.gordon")
}

With old Gradle plugins syntax

build.gradle of your root project

buildscript {
    repositories {
        gradlePluginPortal()
        google()
        mavenCentral()
    }

    dependencies {
        classpath "com.banno.gordon:gordon-plugin:$gordonVersion"
    }
}

build.gradle of any modules for which you want to run tests using Gordon

apply plugin: "com.banno.gordon"

buildSrc

If you have a buildSrc module, you may also need to add the dependency there if you get aapt2 errors.

build.gradle.kts of your buildSrc module

repositories {
    gradlePluginPortal()
    google()
    mavenCentral()
}

dependencies {
    implementation("com.banno.gordon:gordon-plugin:$gordonVersion")
}

Configuring

build.gradle.kts of any module for which you've applied Gordon

import com.banno.gordon.PoolingStrategy

gordon {
    // Default is PoolingStrategy.PoolPerDevice
    poolingStrategy.set(PoolingStrategy.PhonesAndTablets)
    //or
    poolingStrategy.set(
        PoolingStrategy.Manual(
            mapOf(
                "poolOne" to setOf("deviceSerial1", "deviceSerial2"),
                "poolTwo" to setOf("deviceSerial3", "deviceSerial4")
            )
        )
    )

    // Default is unset (`-1`) - to use "tablet" characteristic instead of size
    tabletShortestWidthDp(720)

    // Default is 0
    retryQuota.set(2)

    // Default is 120_000 (2 minutes)
    installTimeoutMillis.set(180_000)

    // Default is 120_000 (2 minutes)
    testTimeoutMillis.set(60_000)

    // Default is no filter
    testFilter.set("ExampleTest.runThisMethod,RunThisWholeTestClass,com.example.runthispackage,com.example.RunTestsWithThisAnnotation")

    // Default is false - to ignore devices that failed during artifacts installation, may be useful with large number of devices and SinglePool strategy
    ignoreProblematicDevices.set(true)
}
Groovy build.gradle example for PoolingStrategy
import com.banno.gordon.PoolingStrategy

gordon {
    poolingStrategy.set(PoolingStrategy.PhonesAndTablets.INSTANCE)
    //or
    poolingStrategy.set(
            new PoolingStrategy.Manual(
                    [
                            "poolOne": ["deviceSerial1", "deviceSerial2"].toSet(),
                            "poolTwo": ["deviceSerial3", "deviceSerial4"].toSet()
                    ]
            )
    )
}

Pooling strategies

  • PoolPerDevice - each device is its own pool, so each test will run on each device
  • SinglePool - all devices make up one pool, so each test will run only once, on an unspecified device
  • PhonesAndTablets - devices are split into pools based on type, so each test will run on one phone and one tablet
    • If the tabletShortestWidthDp property is set, devices with at least that dimension will be considered "tablets"
    • If tabletShortestWidthDp is not set, devices with tablet in their ro.build.characteristics build property will be considered "tablets"
  • Manual - create your own pools with specific devices - each test will run on one device from each pool

Compatibility with Android extension

Gordon is compatible with most testing options that can be configured in the Android extension, including size/annotation/notAnnotation arguments and disabling animations for tests. Note that you can also specify annotations using Gordon's test filtering options instead of using instrumentation runner arguments.

Example build.gradle.kts

android {
    defaultConfig {
        testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"

        testInstrumentationRunnerArgument("size", "medium")
        testInstrumentationRunnerArgument("notAnnotation", "androidx.test.filters.FlakyTest")

        testOptions.animationsDisabled = true
    }
}

In this example, the AndroidX AndroidJUnitRunner will be used, animations will be disabled, and the only tests run will be those annotated with @MediumTest, but not @FlakyTest.

Running

Tasks

Gordon registers a Gradle task for each tested variant, stripping testBuildType (normally Debug) from the task name because it's redundant.

For example, if you have no flavors defined, the following task is registered:

  • gordon - the equivalent of connectedDebugAndroidTest

If you have a mode dimension with demo and full flavors, plus a staging build type in addition to the standard debug and release types, and you set your testBuildType to staging, the following tasks are registered:

  • gordonDemo - the equivalent of connectedDemoStagingAndroidTest
  • gordonFull - the equivalent of connectedFullStagingAndroidTest

Filtering

There is a --tests commandline option that overrides the testFilter set in the gordon extension if both are specified.

Examples

  • ./gradlew gordon
  • ./gradlew gordon --tests=ExampleTest.runThisMethod
  • ./gradlew gordon --tests=RunThisWholeTestClass
  • ./gradlew gordon --tests=ExampleTest.runThisMethod,com.example.runthispackage
  • ./gradlew gordon --tests=com.example.RunTestsWithThisAnnotation

Retries

If a retry quota is specified, Gordon will, after trying tests once, first retry any tests that were not able to run because of device issues, up to the specified quota per test case, and then retry any failing tests, up to the specified quota per test case. If multiple devices are available in a pool, a failing test will be retried on a different device from the one on which it originally failed.

Reports

Gordon generates junit reports in the build directory / test-results, and an HTML report in the build directory / reports.

Other notes

Why we named our test runner Gordon

Gordon

License

   Copyright 2019 Jack Henry & Associates, Inc.

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.

More Repositories

1

polymer-webpack-loader

WebPack Loader for Polymer Web Components
JavaScript
192
star
2

getsentry-ldap-auth

A Sentry extension to add an LDAP server as an authention source.
Python
163
star
3

kafka4s

Functional programming with Kafka and Scala
Scala
92
star
4

polymer-2-starter-kit-webpack

Polymer 2 Starter Kit and Webpack
HTML
38
star
5

packer-post-processor-vsphere-ova

This post-processor will upload a VMDK and vmware template to a datastore on VSphere 5.5
Go
33
star
6

druid-docker

Docker containers for Druid nodes
Scala
28
star
7

knife-whisk

Knife plugin to generate knife server create commands
Ruby
26
star
8

salat-avro

Fast bi-directional Scala case class to Avro serialization
Scala
23
star
9

asdf-kustomize

asdf plugin for installing kustomize
Shell
22
star
10

vault4s

Vault Client Library For Scala
Scala
19
star
11

graphite-setup

Graphite in your docker.
Ruby
17
star
12

sbt-license-plugin

sbt plugin for adding/updating license headers in source files
Scala
16
star
13

simple-plugin-example

Companion example app to the Plugin Quickstart
EJS
16
star
14

banno-powerons

Banno PowerOn library
IDL
15
star
15

consumer-api-openid-connect-example

Example of how to connect to Banno services using OpenID Connect (an identity layer on top of OAuth 2.0)
JavaScript
14
star
16

vagrant-mesos

Local Mesos cluster in Vagrant
Shell
12
star
17

akka-event-handler-flume

flume sink for your akka event handler
Scala
11
star
18

grunt-coffeeify

JavaScript
11
star
19

web-component-router

Framework independent router for web-components based apps
JavaScript
10
star
20

docker-hbase-standalone

Repo for Docker Trusted build banno/docker-hbase-standalone
Shell
9
star
21

sbt-plantuml-plugin

An sbt plugin to generate sequence diagrams from text files.
Java
9
star
22

jsonz

Yet another Scala json parsing library blending together the better ideas
Scala
9
star
23

hadoop-nagios

Ruby
9
star
24

terraform-provider-vsphere

VMware VSphere provider for Terraform
Go
9
star
25

terraform-provider-mesoskafka

Terraform Provider for the Mesos Kafka Scheduler API
Go
8
star
26

kube-ingress-index

index page linking to Kubernetes Ingress objects
Go
8
star
27

heatblast

A Mesos framework for scheduling Samza jobs.
Scala
6
star
28

google-actions-demo

Use the Banno Consumer API to power Google Assistant actions
JavaScript
5
star
29

scala-webframework-faceoff

Scala
5
star
30

jha-design

Design specification for JHA web apps
HTML
5
star
31

bower-sinopia-resolver

Custom resolver for bower allowing sinopia to be used as a registry
JavaScript
5
star
32

getsentry-kafka

An Apache Kafka plugin for Sentry
Python
4
star
33

polymer-rename

Rename polymer template databinding expressions and event functions with closure-compiler
JavaScript
4
star
34

FDL

Digital UX Field Definition Language
JavaScript
3
star
35

node-mock-rest-middleware

Simple middleware for mocking REST services
JavaScript
3
star
36

ninja-binaries

Contains binaries of the Ninja build system
Shell
3
star
37

polymer-lint

Linter for polymer web components
JavaScript
3
star
38

banno-client-creds-helper

Helper utilities for common tasks with Banno's Platform API
JavaScript
3
star
39

docker-elasticsearch-mesos

Elasticsaerch running as a mesos framework, in a docker container to be ran by marathon.
Shell
2
star
40

twitter-streaming

My approach to computing the top 5 hashtags in Twitter's Streaming API
Scala
2
star
41

docker-rabbitmq

rabbitmq docker image
Shell
2
star
42

asdf-jsonnet

Shell
2
star
43

basic-plugin-example

JavaScript
2
star
44

cosmos4s

Cosmos Access Api
Scala
2
star
45

semgrep-scalafix

scalafix rules that mimic some semgrep ones
Scala
1
star
46

samza-mesos-docker

Base Docker image for Samza jobs on Mesos
1
star
47

simple-announcements-plugin

A sample plugin for use with tutorial
JavaScript
1
star
48

terraform-provider-null

Go
1
star
49

getsentry-javascript-lite

Python
1
star
50

whampire

Go
1
star
51

ux-license-report

Generates license reports of 3rd-party software dependencies
JavaScript
1
star
52

banno-plugin-framework-bridge

JavaScript message bridge for Banno Plugins
JavaScript
1
star