• Stars
    star
    189
  • Rank 204,649 (Top 5 %)
  • Language
    Kotlin
  • License
    Apache License 2.0
  • Created over 5 years ago
  • Updated almost 2 years ago

Reviews

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

Repository Details

BusyBee is an alternative API for IdlingResources in Espresso tests

BusyBee - Tell Espresso when it needs to be patient because your app is busy 🐝

BusyBee is an alternative API for IdlingResources in Espresso tests. You can use BusyBee instead of CountingIdlingResource to get better log messages and improve your ability to debug problems related to IdlingResources.

BusyBee is meant to be used with Espresso. You use BusyBee inside the "app under test". It allows the "app under test" to tell Espresso when it is busyWith an operation and, conversely, allows the app to tell Espresso when the operation is completed. Tracking busyWith/completed helps your Espresso tests be fast and reliable.

If you write Espresso tests, proper use of the IdlingResource API is critical for ensuring that your tests are fast and reliable. IdlingResource can be hard to use correctly and it can be hard to understand what is happening with your IdlingResources when you are debugging problems with your tests. That is where BusyBee comes in.

Comparison with CountingIdlingResource

In some ways, BusyBee is similar to CountingIdlingResource, but it does have some notable advantages:

  • Rather than track only the number of operations in progress, BusyBee keeps track of the set of operations currently in progress. In progress operations are represented by a Java object, which could be a string, request object, etc. This allows for easier debugging, as it allows you to inspect the set of in progress operations across the whole app.
  • When Espresso times out because the app is busy, your logs can show the list of in progress operations.
  • BusyBee lets you separately enable/disable tracking of specific categories of operations (e.g. NETWORK operations)
  • The BusyBee#completed(thing) method is idempotent (CountingIdlingResource#decrement is not). This is useful when you have unreliable/multiple signals (e.g. WebView) to tell you that an operation has completed. Also, you can completed(thing) even if you never were busyWith(thing)

Trade-off: While there are a number of advantages listed above, the downside of BusyBee (and CountingIdlingResource) is that you are modifying your app under test for purely testing purposes.

How to use BusyBee

Include the BusyBee dependencies in your build.gradle files. When tests are not running, the no-op implementation is automatically used to minimize overhead of BusyBee (since it is only needed during tests).

Find the latest version on Maven Central

Required: For Android modules:

    implementation 'io.americanexpress.busybee:busybee-android:$version'

Optional: Only needed, if you want to use BusyBee in a non-Android module:

    implementation 'io.americanexpress.busybee:busybee-core:$version'

BusyBee releases are available on Maven Central.

    repositories {
        exclusiveContent {
            forRepository { mavenCentral() }
            filter { includeGroup("io.americanexpress.busybee") }
        }
    }    

On each merge to main, a -SNAPSHOT version is published to https://s01.oss.sonatype.org/content/repositories/snapshots/

Inside your app, tell BusyBee what operations your app is busyWith, and when that operation is completed.

    class BackgroundProcessor {
        private final BusyBee busyBee = BusyBee.singleton();

        void processThing(Thing thing){
            // Espresso will wait
            busyBee.busyWith(thing);
            try {
                thing.process();
            } finally {
                // Espresso will continue
                busyBee.completed(thing);
            }
        }
    }

That's all! Now Espresso will wait until your app is not busy before executing its actions and assertions.

Categories

Assigning a Category to your operations is an advanced feature of BusyBee. By default, all operations are in the GENERAL category. But, you can also add operations in other categories such as NETWORK. You can toggle tracking for any category with payAttentionToCategory/ignoreCategory. When a category is being "ignored" then Espresso will not wait for operations in that category.

For example, you might want to perform actions on your UI or assert things about your UI while a network request is still in progress. In this case, you don't want Espresso to wait for the network requests to complete, but you still want Espresso to wait for other operations in your app. To accomplish this, you would use busyBee.ignoreCategory(NETWORK), then perform actions and assertions on your UI, then call busybee.payAttentionToCategory(NETWORK) so Espresso will again wait for network operations to complete.

BusyBeeExecutorWrapper

If you have an executor and you need Espresso to know the app is "busy" anytime that executor is executing something, then you can wrap the Executor with BusyBeeExecutorWrapper. Operations executed with the wrapped Executor will cause BusyBee to be "busy" while they are in progress.

   Executor backgroundTasks;
   Executor busyBeeBackgroundTasks =
                         BusyBeeExecutorWrapper.with(busyBee)
                                               .wrapExecutor(backgroundTasks)
                                               .build();
    busyBeeBackgroundTasks.execute(operation);

Contributing

We welcome Your interest in the American Express Open Source Community on Github. Any Contributor to any Open Source Project managed by the American Express Open Source Community must accept and sign an Agreement indicating agreement to the terms below. Except for the rights granted in this Agreement to American Express and to recipients of software distributed by American Express, You reserve all right, title, and interest, if any, in and to Your Contributions. Please fill out the Agreement.

License

Any contributions made under this project will be governed by the Apache License 2.0.

The Android™ robot is reproduced or modified from work created and shared by Google and used according to terms described in the Creative Commons 3.0 Attribution License. Android is a trademark of Google Inc.

Code of Conduct

This project adheres to the American Express Community Guidelines. By participating, you are expected to honor these guidelines.

More Repositories

1

jest-image-snapshot

✨ Jest matcher for image comparisons. Most commonly used for visual regression testing.
JavaScript
3,821
star
2

react-albus

✨ React component library for building declarative multi-step flows.
JavaScript
1,094
star
3

earlybird

EarlyBird is a sensitive data detection tool capable of scanning source code repositories for clear text password violations, PII, outdated cryptography methods, key files and more.
Go
697
star
4

xcprojectlint

A security blanket for Xcode project files
Swift
504
star
5

nodes

A GraphQL JVM Client - Java, Kotlin, Scala, etc.
Java
307
star
6

one-app

✨ a fresh, modular take on web application development
JavaScript
292
star
7

baton

HTTP load testing witten in Go
Go
264
star
8

iguazu

✨ Iguazu is a simple Redux-powered Async Query engine
JavaScript
202
star
9

jest-json-schema

✨ JSON schema matcher for Jest
JavaScript
169
star
10

parrot

✨ Scenario-based HTTP mocking
JavaScript
137
star
11

unify-flowret

A lightweight Java based orchestration engine
Java
98
star
12

holocron

✨Set of packages that are used to compose and load React components, enabling the updating and launching of server side rendered user experiences without server restarts
JavaScript
80
star
13

unify-jdocs

A new way of working with JSON documents without using model classes or JSON schemas
Java
72
star
14

hyperledger-fabric-sdk-php

Client SDK for Hyperledger Fabric for use in PHP applications
PHP
47
star
15

react-seo

✨ Simple SEO tag manager for React
JavaScript
45
star
16

fetchye

✨ If you know how to use Fetch, you know how to use Fetchye [fetch-yae]. Simple React Hooks, Centralized Cache, Infinitely Extensible.
JavaScript
41
star
17

eslint-config-amex

✨ This is American Express' eslint config
JavaScript
40
star
18

one-app-cli

✨A set of command line interface (CLI) tools for bundling One App, it's modules, and property files(locale and environment specific files).
JavaScript
36
star
19

k8s-prometheus-proxy

JavaScript
28
star
20

css-to-js

✨ Tool for transforming CSS into JS
JavaScript
28
star
21

grpc-k8s-health-check

A gRPC client-server application illustrating health checks of gRPC servers on Kubernetes
Go
27
star
22

amex-api-java-client-core

Library for authenticating with APIs published to the Amex for Developers portal.
Java
26
star
23

simplemli

Encode and Decode Message Length Indicators for TCP/IP socket based protocols
Go
25
star
24

synapse

Synapse is a set of lightweight foundational framework modules for rapid development, built-in with enterprise-grade maturity and quality.
Java
25
star
25

sfdx-cli-plugin

A plugin for the Salesforce DX CLI based on the Open CLI Framework (OCLIF)
TypeScript
24
star
26

one-service-worker

✨ Minimal, light-weight, Promise based library that unifies the service worker and browser threads under one API
JavaScript
23
star
27

purgecss-loader

✨ A Webpack loader to strip unused selectors from your CSS
JavaScript
22
star
28

redux-lifesaver

✨ redux-lifesaver is a middleware that keeps track of how many times actions of the same type are dispatched within a given period.
JavaScript
22
star
29

iguazu-rest

✨ Iguazu REST is a plugin for the Iguazu ecosystem that allows for pre-built async calls for REST with smart caching.
JavaScript
21
star
30

bucketlist

See what's in your BitBucket Server
Kotlin
18
star
31

react-conditional-flow

React components on top of control flow operations like if, if-else, if-else-if, switch-case, & try-catch
JavaScript
17
star
32

redux-idle-callback

✨ Redux middleware to dispatch actions during a Redux store's idle periods
JavaScript
16
star
33

babel-preset-amex

✨ Standard babel preset for American Express
JavaScript
16
star
34

iguazu-graphql

✨ Iguazu GraphQL is a plugin for the Iguazu ecosystem that allows for GraphQL requests backed by a simple cache.
JavaScript
16
star
35

amex-jest-preset

✨ An opinionated Jest preset
JavaScript
14
star
36

fetch-enhancers

✨ Library of middleware for enhancing Fetch
JavaScript
13
star
37

amex-jest-preset-react

✨ An opinionated Jest preset for React modules
JavaScript
13
star
38

xcode-result-bundle-processor

xcode-result-bundle-processor converts Xcode test result bundles into friendly HTML reports
Ruby
12
star
39

lumberjack

✨ Lumberjack is a minimal, configurable Console with utilities.
JavaScript
12
star
40

vitruvius

✨Vitruvius extends redux's combineReducers to allow developers to include a buildInitialState method on their reducer
JavaScript
11
star
41

jexm

Library to facilitate reading from Excel files
Java
10
star
42

targeted-offers-client

SDK for AMEX targeted offers API
JavaScript
10
star
43

task-status-pr-checker

This is triggered when a pull request is created. If the pull request has pending tasks. The pull request won't be merged and the status is updated on the pull request checks.
JavaScript
10
star
44

codeandsolve

9
star
45

parrot-jest-image-snapshot-example

✨ Example demonstrating usage of parrot for more deterministic jest-image-snapshot tests
JavaScript
9
star
46

amex-api-dotnet-client-core

Library for authenticating with APIs published to the Amex for Developers portal.
C#
9
star
47

express-checkout-tutorials

Code samples for use with Express Checkout API
HTML
8
star
48

one-app-ducks

✨Redux ducks used within the One App ecosystem.
JavaScript
8
star
49

env-config-utils

✨ Utilities for runtime configuration validations
JavaScript
8
star
50

create-shared-react-context

✨A memoized wrapper around React.createContext. Used by One App as a dependency to pass React context between Holocron modules without external usage.
JavaScript
8
star
51

middle-manager

An easy migration path away from the Java WorkManager concurrency API
Java
7
star
52

dux-socket

WebSocket middleware for Redux applications
JavaScript
7
star
53

one-app-dev-cdn

✨ Load remote modules for local development
JavaScript
7
star
54

gabby

Gabby provides a way to interface with several chatbot providers through "adapters". Adapters interface with different services such as api.ai and Watson Conversation.
TypeScript
7
star
55

json-parse-context

✨ Add the context of a json parse error to the error message with syntax highlighting if possible.
JavaScript
6
star
56

jacos

Java/Spring based SDK to enable insert, update and upsert of files and records in the SalesForce in Bulk, Single Record and Multi Record Mode
Java
6
star
57

react-iterative-flow

JavaScript
6
star
58

one-app-dev-proxy

✨ Proxy requests to remote servers locally while also allowing for an express middleware to be provided and applied to all requests
JavaScript
6
star
59

easydist

An end-to-end distributed deep learning tool that mimics the single-machine keras programming model
Python
6
star
60

findxcprojorphan

Finds source files unreferenced in Xcode project
Ruby
5
star
61

SPAN

A stored procedures framework
Java
5
star
62

jakasu

Powerful config driven SDK to easily consume events from one or multiple Kafka topics in both standard and streaming modes
Java
5
star
63

iguazu-rpc

✨ Iguazu RPC is a plugin for the Iguazu ecosystem that allows for configurable async calls and caching strategies.
JavaScript
5
star
64

fabric-integration

Project born out of a need to have a "stable" interface to the Fabric node SDK across various versions.
TypeScript
5
star
65

mlflow-server-proxy

Jupyter server proxy extension for mlflow tracking server
Python
4
star
66

bloom

BLooM is a configuration driven bigdata framework to load massive data into MemSQL
Java
4
star
67

suwannee

RESTful API to enable smart contract interaction from any language or platform
TypeScript
4
star
68

create-using-template

JavaScript
4
star
69

un-locode-java

Java
4
star
70

dydaq

DyDaQ framework connects GraphQL service layer with database efficiently
Java
4
star
71

omnitransform

Declarative and config driven Big Data/ETL framework based on Apache Spark
Java
3
star
72

rate-limiting-scheduled-executor

Java
3
star
73

jakapu

Config driven SDK to publish events into any Kafka topic without writing code
Java
3
star
74

yelp-search

Programmatically search Yelp for businesses using the public version 2.0 of the Yelp Search API
Swift
3
star
75

hide

Config Driven Big Data component which can generate data extracts in various formats from any Hive Tables
Shell
3
star
76

connectchain

Python
2
star
77

chaincode-guide

1
star