dependencies{// Core libraryandroidTestImplementation"androidx.test:core:$androidXTestVersion0"// AndroidJUnitRunner and JUnit RulesandroidTestImplementation"androidx.test:runner:$testRunnerVersion"androidTestImplementation"androidx.test:rules:$testRulesVersion"// AssertionsandroidTestImplementation"androidx.test.ext:junit:$testJunitVersion"androidTestImplementation"androidx.test.ext:truth:$truthVersion"// Espresso dependenciesandroidTestImplementation"androidx.test.espresso:espresso-core:$espressoVersion"androidTestImplementation"androidx.test.espresso:espresso-contrib:$espressoVersion"androidTestImplementation"androidx.test.espresso:espresso-intents:$espressoVersion"androidTestImplementation"androidx.test.espresso:espresso-accessibility:$espressoVersion"androidTestImplementation"androidx.test.espresso:espresso-web:$espressoVersion"androidTestImplementation"androidx.test.espresso.idling:idling-concurrent:$espressoVersion"// The following Espresso dependency can be either "implementation",// or "androidTestImplementation", depending on whether you want the// dependency to appear on your APK’"s compile classpath or the test APK// classpath.androidTestImplementation"androidx.test.espresso:espresso-idling-resource:$espressoVersion"}
Kotlin
dependencies{// Core libraryandroidTestImplementation("androidx.test:core:$androidXTestVersion")// AndroidJUnitRunner and JUnit RulesandroidTestImplementation("androidx.test:runner:$testRunnerVersion")androidTestImplementation("androidx.test:rules:$testRulesVersion")// AssertionsandroidTestImplementation("androidx.test.ext:junit:$testJunitVersion")androidTestImplementation("androidx.test.ext:truth:$truthVersion")// Espresso dependenciesandroidTestImplementation("androidx.test.espresso:espresso-core:$espressoVersion")androidTestImplementation("androidx.test.espresso:espresso-contrib:$espressoVersion")androidTestImplementation("androidx.test.espresso:espresso-intents:$espressoVersion")androidTestImplementation("androidx.test.espresso:espresso-accessibility:$espressoVersion")androidTestImplementation("androidx.test.espresso:espresso-web:$espressoVersion")androidTestImplementation("androidx.test.espresso.idling:idling-concurrent:$espressoVersion")// The following Espresso dependency can be either "implementation",// or "androidTestImplementation", depending on whether you want the// dependency to appear on your APK"s compile classpath or the test APK// classpath.androidTestImplementation("androidx.test.espresso:espresso-idling-resource:$espressoVersion")}
지원 중단된 JUnit3 기반 android.test 클래스를 사용하는 테스트를 실행하려면 필요한 <uses-library> 요소를 테스트 앱의 매니페스트에 추가합니다. 예를 들어 android.test.runner 라이브러리에 종속된 테스트를 추가한다면 다음 요소를 앱의 매니페스트에 추가하세요.
<!--Youdon't need to include android:required="false" if your app'sminSdkVersionis28orhigher.-->
<uses-libraryandroid:name="android.test.runner"android:required="false"/>
지정된 JUnit 기반 클래스를 포함하는 라이브러리를 판별하려면 JUnit 기반 라이브러리를 참고하세요.
지원 중단된 클래스를 사용하고 Android 9 이상을 타겟팅할 때 고려사항
높음
이 섹션의 안내 사항은 Android 9 (API 수준 28) 이상을 타겟팅하고 또한 앱의 최소 SDK 버전이 Android 9로 설정되어 있는 경우에만 적용됩니다.
android.test.runner 라이브러리는 android.test.base 및 android.test.mock 라이브러리에 암시적으로 종속됩니다. 앱이 android.test.base 또는 android.test.mock의 클래스만 사용하는 경우 단독으로 라이브러리를 포함할 수 있습니다.
<!--Forbothofthesedeclarations,youdon't need to include android:required="false" if your app'sminSdkVersionis28orhigher.-->
<uses-libraryandroid:name="android.test.base"android:required="false"/>
<uses-library android:name="android.test.mock" android:required="false" />
이 페이지에 나와 있는 콘텐츠와 코드 샘플에는 콘텐츠 라이선스에서 설명하는 라이선스가 적용됩니다. 자바 및 OpenJDK는 Oracle 및 Oracle 계열사의 상표 또는 등록 상표입니다.
최종 업데이트: 2025-08-08(UTC)
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["필요한 정보가 없음","missingTheInformationINeed","thumb-down"],["너무 복잡함/단계 수가 너무 많음","tooComplicatedTooManySteps","thumb-down"],["오래됨","outOfDate","thumb-down"],["번역 문제","translationIssue","thumb-down"],["샘플/코드 문제","samplesCodeIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-08-08(UTC)"],[],[],null,["# Set up project for AndroidX Test\n\nAndroidX Test is a collection of Jetpack libraries that lets you run tests\nagainst Android apps. It also provides a series of tools to help you write these\ntests.\n\nFor example, AndroidX Test provides JUnit4 rules to start activities and\ninteract with them in JUnit4 tests. It also contains UI Testing frameworks such\nas Espresso, UI Automator and the Robolectric simulator.\n\nAdd AndroidX Test libraries\n---------------------------\n\nIn order to use AndroidX Test, you must modify your app project's dependencies\nwithin your development environment.\n\n### Add Gradle dependencies\n\nTo modify your app project's dependencies, complete the following steps:\n\n- **Step 1** : Open the `build.gradle` file for your Gradle module.\n- **Step 2**: In the repositories section, make sure Google's Maven repository appears:\n\n allprojects {\n repositories {\n jcenter()\n google()\n }\n }\n\n- **Step 3** : For each AndroidX Test package you want to use, add its package name to the dependencies section. For example, to add the `espresso-core` package, add the following lines:\n\n### Groovy\n\n```groovy\ndependencies {\n ...\n androidTestImplementation \"androidx.test.espresso:espresso-core:$espressoVersion\"\n }\n```\n\n### Kotlin\n\n```kotlin\ndependencies {\n ...\n androidTestImplementation('androidx.test.espresso:espresso-core:$espressoVersion')\n }\n```\n\nThese are the most common AndroidX Test dependencies available: \n\n### Groovy\n\n```groovy\ndependencies {\n // Core library\n androidTestImplementation \"androidx.test:core:$androidXTestVersion0\"\n\n // AndroidJUnitRunner and JUnit Rules\n androidTestImplementation \"androidx.test:runner:$testRunnerVersion\"\n androidTestImplementation \"androidx.test:rules:$testRulesVersion\"\n\n // Assertions\n androidTestImplementation \"androidx.test.ext:junit:$testJunitVersion\"\n androidTestImplementation \"androidx.test.ext:truth:$truthVersion\"\n\n // Espresso dependencies\n androidTestImplementation \"androidx.test.espresso:espresso-core:$espressoVersion\"\n androidTestImplementation \"androidx.test.espresso:espresso-contrib:$espressoVersion\"\n androidTestImplementation \"androidx.test.espresso:espresso-intents:$espressoVersion\"\n androidTestImplementation \"androidx.test.espresso:espresso-accessibility:$espressoVersion\"\n androidTestImplementation \"androidx.test.espresso:espresso-web:$espressoVersion\"\n androidTestImplementation \"androidx.test.espresso.idling:idling-concurrent:$espressoVersion\"\n\n // The following Espresso dependency can be either \"implementation\",\n // or \"androidTestImplementation\", depending on whether you want the\n // dependency to appear on your APK'\"s compile classpath or the test APK\n // classpath.\n androidTestImplementation \"androidx.test.espresso:espresso-idling-resource:$espressoVersion\"\n}\n```\n\n### Kotlin\n\n```kotlin\ndependencies {\n // Core library\n androidTestImplementation(\"androidx.test:core:$androidXTestVersion\")\n\n // AndroidJUnitRunner and JUnit Rules\n androidTestImplementation(\"androidx.test:runner:$testRunnerVersion\")\n androidTestImplementation(\"androidx.test:rules:$testRulesVersion\")\n\n // Assertions\n androidTestImplementation(\"androidx.test.ext:junit:$testJunitVersion\")\n androidTestImplementation(\"androidx.test.ext:truth:$truthVersion\")\n\n // Espresso dependencies\n androidTestImplementation( \"androidx.test.espresso:espresso-core:$espressoVersion\")\n androidTestImplementation( \"androidx.test.espresso:espresso-contrib:$espressoVersion\")\n androidTestImplementation( \"androidx.test.espresso:espresso-intents:$espressoVersion\")\n androidTestImplementation( \"androidx.test.espresso:espresso-accessibility:$espressoVersion\")\n androidTestImplementation( \"androidx.test.espresso:espresso-web:$espressoVersion\")\n androidTestImplementation( \"androidx.test.espresso.idling:idling-concurrent:$espressoVersion\")\n\n // The following Espresso dependency can be either \"implementation\",\n // or \"androidTestImplementation\", depending on whether you want the\n // dependency to appear on your APK\"s compile classpath or the test APK\n // classpath.\n androidTestImplementation( \"androidx.test.espresso:espresso-idling-resource:$espressoVersion\")\n}\n```\n\nThe [Release Notes](/jetpack/androidx/releases/test) page contains a table with the latest versions per\nartifact.\n| **Note:** It's important to ensure these testing dependencies point to the correct source set. Usually AndroidX Test is needed in instrumentation tests only, so you would use `androidTestImplementation()`. However, in cases such as with `espresso-idling-resource`, the APIs are used from production code, requiring you to use the implementation function.\n\nRefer to the [Package Index](/reference/androidx/test/packages) or [Class Index](/reference/androidx/test/classes) for specific reference\ndocumentation on these libraries.\n\nProjects using deprecated classes\n---------------------------------\n\n| **Warning:** If you build instrumentation tests using Gradle, you receive additional support. When auto-generating the test manifest, the Android Gradle Plugin adds the following libraries and manifest elements to your project automatically so you don't need to take these steps.\n\nIf your app uses tests that rely on deprecated JUnit3-based `android.test`\nclasses , such as [`InstrumentationTestCase`](/reference/android/test/InstrumentationTestCase) and [`TestSuiteLoader`](/reference/junit/runner/TestSuiteLoader), add\nthe following lines in the `android` section of the file: \n\n android {\n ...\n useLibrary 'android.test.runner'\n\n useLibrary 'android.test.base'\n useLibrary 'android.test.mock'\n }\n\n| **Note:** You only need to include the libraries that contain the classes used in your app. For a list of the classes that appear in each library, see [JUnit-based libraries](/training/testing/instrumented-tests/androidx-test-libraries/test-setup).\n\n### Add manifest declarations\n\nTo run tests that rely on deprecated JUnit3-based `android.test` classes, add\nthe necessary [`\u003cuses-library\u003e`](/guide/topics/manifest/uses-library-element) elements to your test app's manifest. For\nexample, if you add tests that depend on the `android.test.runner` library, add\nthe following element to your app's manifest: \n\n \u003c!-- You don't need to include android:required=\"false\" if your app's\n\n minSdkVersion is 28 or higher. --\u003e\n\n \u003cuses-library android:name=\"android.test.runner\"\n\n android:required=\"false\" /\u003e\n\nTo determine the library that contains a given JUnit-based class, see\n[JUnit-based libraries](/training/testing/instrumented-tests/androidx-test-libraries/test-setup).\n| **Caution:** Avoid deprecated classes where possible. Use supported JUnit-based classes in their place.\n\n#### Considerations when using deprecated classes and targeting Android 9 or\n\nhigher\n\nThe guidance in this section applies only if you target Android 9 (API level 28)\nor higher *and* the minimum SDK version for your app is set to Android 9.\n\nThe `android.test.runner` library implicitly depends on the `android.test.base`\nand `android.test.mock` libraries. If your app only uses classes from\n`android.test.base` or `android.test.mock`, you can include the libraries by\nthemselves: \n\n \u003c!-- For both of these declarations, you don't need to include\n android:required=\"false\" if your app's minSdkVersion is 28\n or higher. --\u003e\n\n \u003cuses-library android:name=\"android.test.base\"\n android:required=\"false\" /\u003e\n \u003cuses-library android:name=\"android.test.mock\"\n android:required=\"false\" /\u003e"]]