Skip to content

Latest commit

 

History

History
95 lines (67 loc) · 3.48 KB

CONTRIBUTING.md

File metadata and controls

95 lines (67 loc) · 3.48 KB

Contributing

Prerequisites

First ensure you have the JDK installed:

brew install openjdk@17

Next, ensure you have the Android SDK installed, which can be installed with Android Studio. You will need to have the adb CLI available in your PATH, which can be done after installing Android Studio by adding the following to your ~/.zshrc or ~/.bash_profile:

export PATH=~/Library/Android/sdk/tools:$PATH
export PATH=~/Library/Android/sdk/platform-tools:$PATH

Set Build Configuration

The following properties are required at build time

  • com.basistheory.android.example.apiUrl: Either the dev (default) or production Basis Theory API URL
  • com.basistheory.android.example.apiKey: A Basis Theory API key with token:create permission and a REVEAL transform on the / container

These properties can be set in many ways, in order of priority (see this reference):

  1. Within the ./local.properties file (this is specific to our setup)
  2. Gradle command line args provided with -P
  3. Java system properties using -D
  4. Environment variables specified with the ORG_GRADLE_PROJECT_ prefix
  5. User specific gradle.properties file at ~/.gradle/gradle.properties
  6. Module level gradle.properties files in the root of a submodule
  7. Root level ./gradle.properties file in the root of a repository

It is recommended that you define these properties within the ./local.properties file for local development by copying the ./local.properties.example file to ./local.properties and setting the desired values.

These properties will be injected at build time into the example app and will be accessible through the BuildConfig class within the example module.

Build the SDK and Install Dependencies

The following command builds both the example app and SDK library:

./gradlew build -x test

Note: The command ./gradlew build is also valid, but it runs all unit tests too.

Running tests

You can run all tests locally by simply executing the command:

make verify

For more fine-grained control when running test suites, see the sections below.

Unit Tests

Unit tests are written against the lib module using Robolectric. To run unit tests, execute the command:

./gradlew test

Acceptance Tests

Acceptance tests rely upon the example module to provide an Android app that uses the lib module, simulating a real user of our Android Library. Acceptance tests are written using Espresso and rely upon an emulator being configured and running on your local machine. An emulator should come pre-installed with Android Studio, or you can follow these instructions to set up a new virtual device to run on your machine.

Once the emulator is booted and available, you can run Espresso tests through Android Studio or by executing the command:

./gradlew connectedCheck

Troubleshooting

If you receive a 400 error while tokenizing within the example app due to 'expires_at' must be a future datetime, it is likely due to skew between your local system clock and the Android emulator. To resync the clock on the emulator with your local system, run:

make emulator-sync-clock