Skip to main content
Version: 2.0.0

Set up testify-compose

Maven Central

Prerequisites

In order to use the Android Testify Compose extension, you must first configure the Testify Plugin on your project. To set up Testify for your project, please refer to the Getting Started guide.

Root build.gradle

buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath "dev.testify:plugin:2.0.0"
}
}

Project configuration

The Android Testify Compose extension is packaged as a separate artifact. You must add an androidTestImplementation statement to your build.gradle file to import it.

Application build.gradle

dependencies {
androidTestImplementation "dev.testify:testify-compose:2.0.0"
androidTestImplementation "androidx.test:rules:1.5.0"
androidTestImplementation "androidx.compose.ui:ui-test-junit4:1.4.3"
}

Manifest

The Testify Compose Extension comes with a preconfigured test harness Activity that is used to host your composables. To use the ComposableTestActivity in your test, you must declare it in your AndroidManifest.xml.

The ComposableTestActivity is only referenced from Debug builds, so you can create a new file in the Debug source set (/src/debug/AndroidManifest.xml) with the following:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<application>
<!--suppress AndroidDomInspection -->
<activity android:name="dev.testify.ComposableTestActivity" />
</application>
</manifest>
tip

You need to use a Theme.AppCompat theme (or descendant) with ComposableTestActivity. Theme.AppCompat.NoActionBar is a suitable choice.

android:theme="@style/Theme.AppCompat.NoActionBar"