Step #2: Adding Some Instrumented Test Dependencies

Right now, our dependencies closure in app/build.gradle has two androidTestImplementation statements:

  androidTestImplementation 'androidx.test.ext:junit:1.1.3'
  androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'

Add these lines to those:

  androidTestImplementation "androidx.arch.core:core-testing:2.1.0"
  androidTestImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.5.1'

The androidx.arch.core:core-testing library contains some JUnit rules and related classes that are commonly needed in Android app testing.

Similarly, the org.jetbrains.kotlinx:kotlinx-coroutines-test library is one that we used in unit testing, but we now also want to use it for instrumented testing.

Also, add these lines inside the android closure:

  packagingOptions {
    exclude 'META-INF/AL2.0'
    exclude 'META-INF/LGPL2.1'
  }

Sometimes, libraries package open source license files along with their compiled code. And, sometimes, that results in collisions, where two libraries put the same license text in the same files. This snippet of Gradle code says to exclude all of those from the app that we are building.


Prev Table of Contents Next

This book is licensed under the Creative Commons Attribution-ShareAlike 4.0 International license.