composer


Source link: https://github.com/gojuno/composer

Composer — Reactive Android Instrumentation Test Runner.

Composer is a modern reactive replacement for square/spoon with following feature set:

  • Parallel test execution on multiple emulators/devices with test sharding support.
  • Logcat output capturing per test and for whole test run as well.
  • Screenshots and files pulling for each test reactively (with support for square/spoon folder structure).
  • JUnit4 report generation.

Table of Contents

Why we've decided to replace square/spoon

Problem 1: Our UI tests are stable, but we saw a lot of UI tests build failures. About ~50% of our CI builds were failing. All such failures of UI tests came from Spoon not being able to run tests on one or more emulators (device is red in the report and error message is …work/emulator-5554/result.json (No such file or directory), basically it timed out on installing the apk on a device, increasing adb timeout did not help, all emulators responded to adb commands and mouse/keyboard interactions, we suppose problem is in in ddmlib used by Spoon.

Solution: Composer does not use ddmlib and talks to emulators/devices by invoking adb binary.

Problem 2: Pretty often when test run finished, Spoon freezed on moving screenshots from one of the emulators/devices. Again, we blame ddmlib used in Spoon for that.

Solution: Composer invokes adb binary to pull files from emulators/devices, we haven't seen problems with that in more than 700 builds on CI.

Problem 3: Spoon pulled screenshots/files after finish of the whole test run on a device which slows down builds: test_run_time + pull_files_time.

Solution: Composer pulls screenshots/files reactively after each test which basically leads to: ~test_run_time.

Problem 4: If test sharding is enabled (which we do all the time), Spoon HTML report is very hard to look at, especially if you want to find some particular test(s) and it's not failed. You have to either hover mouse over each test to find out its name or go into html/xml source and find on which emulator/device test was sharded in order to click on correct device and then find test by CMD+F on the page.

Solution: HTML report we've built designed with usability and performance in mind.

Problem 5: Html report can be very slow to load if you have lots of screenshots (which we do) since it displays all the screenshots of tests that were run on a particular device on a single page — it can take up to minutes to finish while you effectively unable to scroll page since scroll is jumping up and down each time new screenshot loaded.

Solution: HTML report that we've built does not display screenshots on index and suite pages, screenshots are displayed only on the test page → fast page load.

With Composer we were able to make UI tests required part of CI for Pull Requests. It's fast, reliable and uses RxJava which means that it's relatively easy to add more features combining complex async transformations.

HTML Report

Our Frontend Team helped us build HTML Report for the Composer.

It's fast, small and designed in collaboration with our QAs and Developers who actually use it on daily basis to make it easy to use.

Here are few screenshots:

Usage

Composer shipped as jar, to run it you need JVM 1.8+: java -jar composer-latest-version.jar options.

Supported options

Required
  • --apk
    • Path to application apk that needs to be tested.
  • --test-apk
    • Path to apk with tests.
  • --test-package
    • Android package name of the test apk (Could be parsed from --test-apk, PR welcome).
  • --test-runner
    • Full qualified name of test runner class you're using (Could be parsed from --test-apk, PR welcome).
Optional
  • --help, -help, help, -h
    • Print help and exit.
  • --shard
    • Either true or false to enable/disable test sharding which runs shards tests to available devices/emulators. True by default.
  • --output-directory
    • Either relative or absolute path to directory for output: reports, files from devices and so on. composer-output by default.
  • --instrumentation-arguments
    • Key-value pairs to pass to Instrumentation Runner. Usage example: --instrumentation-arguments myKey1 myValue1 myKey2 myValue2.
  • --verbose-output
    • Either true or false to enable/disable verbose output for Composer. false by default.
  • --devices
    • Connected devices/emulators that will be used to run tests against. If not passed — tests will run on all connected devices/emulators. Specifying both --devices and --device-pattern will result in an error. Usage example: --devices emulator-5554 emulator-5556.
  • --device-pattern
    • Connected devices/emulators that will be used to run tests against. If not passed — tests will run on all connected devices/emulators. Specifying both --device-pattern and --devices will result in an error. Usage example: --device-pattern "emulator.+".
  • --install-timeout
    • APK installation timeout in seconds. If not passed defaults to 120 seconds (2 minutes). Applicable to both test APK and APK under test. Usage example (for 10 minutes timeout): --install-timeout 600.
Example
java -jar composer-latest-version.jar \ --apk app/build/outputs/apk/example-debug.apk \ --test-apk app/build/outputs/apk/example-debug-androidTest.apk \ --test-package com.example.test \ --test-runner com.example.test.ExampleTestRunner \ --output-directory artifacts/composer-output \ --instrumentation-arguments key1 value1 key2 value2 \ --verbose-output false

Download

Composer is available on jcenter.

You can download it in your CI scripts or store it in your version control system (not recommended).

COMPOSER_VERSION=some-version curl --fail --location https://jcenter.bintray.com/com/gojuno/composer/composer/${
COMPOSER_VERSION
}
/composer-${
COMPOSER_VERSION
}
.jar --output /tmp/composer.jar

All the releases and changelogs can be found on Releases Page.

3rd-party Composer Gradle Plugin

@trevjonez built 🎉 Gradle Plugin for Composer which allows you to configure and run Composer with Gradle.

Swarmer

Composer works great in combination with Swarmer — another tool we've built at Juno.

Swarmer can create and start multiple emulators in parallel. In our CI Pipeline we start emulators with Swarmer and then Composer runs tests on them.

How to build

Dependencies: you only need docker and bash installed on your machine.

bash ci/build.sh

License

Copyright 2017 Juno, 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. 

Resources

Tweet Lanes is a fully functional Twitter client, targeted at Android devices running API 14 and above.

QuiltView displays views of different sizes in a scrollable grid.

Robolectric is a unit test framework that de-fangs the Android SDK jar so you can test-drive the development of your Android app. Tests run inside the JVM on your workstation in seconds.

osmdroid is a (almost) full/free replacement for Android's MapView (v1 API) class. It also includes a modular tile provider system with support for numerous online and offline tile sources and overlay support with built-in overlays for plotting icons, tracking location, and drawing shapes.

A carefully crafted Android framework that includes: DI, ORM, EventBus, JSON (de)serialization feature, improved AsyncTask & IntentService, Logger, RESTClient, ImageFetcher, and a lot of utils.

Android common lib, include ImageCache, HttpCache, DropDownListView, DownloadManager, Utils and so on.

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes