# TestedExtension

# TestedExtension

```
@Incubating interface TestedExtension
```

|------------------------------------------------------------------------------------------------------------------------------------------------------|
| [com.android.build.api.dsl.TestedExtension](https://developer.android.com/reference/tools/gradle-api/7.1/com/android/build/api/dsl/TestedExtension#) |

|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Known Direct Subclasses [ApplicationExtension](https://developer.android.com/reference/tools/gradle-api/7.1/com/android/build/api/dsl/ApplicationExtension),[DynamicFeatureExtension](https://developer.android.com/reference/tools/gradle-api/7.1/com/android/build/api/dsl/DynamicFeatureExtension),[LibraryExtension](https://developer.android.com/reference/tools/gradle-api/7.1/com/android/build/api/dsl/LibraryExtension) |-------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------| | [ApplicationExtension](https://developer.android.com/reference/tools/gradle-api/7.1/com/android/build/api/dsl/ApplicationExtension)       | Extension for the Android Gradle Plugin Application plugin. | | [DynamicFeatureExtension](https://developer.android.com/reference/tools/gradle-api/7.1/com/android/build/api/dsl/DynamicFeatureExtension) | Extension for the Android Dynamic Feature Gradle Plugin.    | | [LibraryExtension](https://developer.android.com/reference/tools/gradle-api/7.1/com/android/build/api/dsl/LibraryExtension)               | Extension for the Android Library Gradle Plugin.            | |

Common extension properties for the Android Application. Library and Dynamic Feature Plugins that relate to testing

Only the Android Gradle Plugin should create instances of this interface.

## Summary

|                                                                                                                                                                                                                                              ### Public methods                                                                                                                                                                                                                                               ||
|--------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| abstract[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [testFixtures](https://developer.android.com/reference/tools/gradle-api/7.1/com/android/build/api/dsl/TestedExtension#testFixtures(kotlin.Function1))`(`action:` `[TestFixtures](https://developer.android.com/reference/tools/gradle-api/7.1/com/android/build/api/dsl/TestFixtures).()` `->` `[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)`)` Options to configure the test fixtures. |

|                                                                                                                                                                                                            ### Properties                                                                                                                                                                                                            ||
|-----------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| abstract[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)                                    | [testBuildType](https://developer.android.com/reference/tools/gradle-api/7.1/com/android/build/api/dsl/TestedExtension#testBuildType:kotlin.String) Specifies the[build type](https://developer.android.com/studio/build/build-variants.html#build-types)that the plugin should use to test the module. |
| abstract[TestFixtures](https://developer.android.com/reference/tools/gradle-api/7.1/com/android/build/api/dsl/TestFixtures) | [testFixtures](https://developer.android.com/reference/tools/gradle-api/7.1/com/android/build/api/dsl/TestedExtension#testFixtures:com.android.build.api.dsl.TestFixtures) Options to configure the test fixtures.                                                                                      |
| abstract[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)?                                   | [testNamespace](https://developer.android.com/reference/tools/gradle-api/7.1/com/android/build/api/dsl/TestedExtension#testNamespace:kotlin.String) The namespace used by the android test and unit test components for the generated R and BuildConfig classes.                                        |

## Public methods

### testFixtures

```
abstract fun testFixtures(action: TestFixtures.() -> Unit): Unit
```

Options to configure the test fixtures.

## Properties

### testBuildType

```
abstract var testBuildType: String
```

Specifies the[build type](https://developer.android.com/studio/build/build-variants.html#build-types)that the plugin should use to test the module.

By default, the Android plugin uses the "debug" build type. This means that when you deploy your instrumented tests using`gradlew connectedAndroidTest`, it uses the code and resources from the module's "debug" build type to create the test APK. The plugin then deploys the "debug" version of both the module's APK and the test APK to a connected device, and runs your tests.

To change the test build type to something other than "debug", specify it as follows:  

```carbon
android {
    // Changes the test build type for instrumented tests to "stage".
    testBuildType "stage"
}
```

If your module configures[product flavors](https://developer.android.com/studio/build/build-variants.html#product-flavors)the plugin creates a test APK and deploys tests for each build variant that uses the test build type. For example, consider if your module configures "debug" and "release" build types, and "free" and "paid" product flavors. By default, when you run your instrumented tests using`gradlew connectedAndroidTest`, the plugin performs executes the following tasks:

- `connectedFreeDebugAndroidTest`: builds and deploys a`freeDebug`test APK and module APK, and runs instrumented tests for that variant.
- `connectedPaidDebugAndroidTest`: builds and deploys a`paidDebug`test APK and module APK, and runs instrumented tests for that variant.

To learn more, read[Create instrumented test for a build variant](https://developer.android.com/studio/test/index.html#create_instrumented_test_for_a_build_variant)

**Note:** You can execute`connected<BuildVariant>AndroidTest`tasks only for build variants that use the test build type. So, by default, running`connectedStageAndroidTest`results in the following build error:  

```text
Task 'connectedStageAndroidTest' not found in root project
```

You can resolve this issue by changing the test build type to "stage".  

### testFixtures

```
abstract val testFixtures: TestFixtures
```

Options to configure the test fixtures.  

### testNamespace

```
abstract var testNamespace: String?
```

The namespace used by the android test and unit test components for the generated R and BuildConfig classes.