diff --git a/docs/html/images/training/testartifactcombined.png b/docs/html/images/training/testartifactcombined.png new file mode 100644 index 0000000000000..a3b5e81c37bec Binary files /dev/null and b/docs/html/images/training/testartifactcombined.png differ diff --git a/docs/html/images/training/testartifactseparate.png b/docs/html/images/training/testartifactseparate.png new file mode 100644 index 0000000000000..b12b70c44dc9f Binary files /dev/null and b/docs/html/images/training/testartifactseparate.png differ diff --git a/docs/html/training/testing/start/index.jd b/docs/html/training/testing/start/index.jd index a4b4aea9ef017..599078c05aa59 100644 --- a/docs/html/training/testing/start/index.jd +++ b/docs/html/training/testing/start/index.jd @@ -162,6 +162,37 @@ dependencies { } +

Work With Test Artifacts

+

Android Studio has two types of test artifacts: Android Instrumentation Tests +and Unit Tests. Previously, you could work with just one test artifact at a +time. Now, both test artifacts are enabled. +The advantage of enabling both test artifacts is that any changes you make to +the underlying code affect +them both. For example, if you rename a class that both test artifacts access, +both will know about the class name refactoring.

+ +

The figure shows what your project looks like with both test +artifacts enabled. Notice the shading of both test artifacts.

+ + + + +

Build and Run Your Tests

You can run build and run your tests in a similar way to how you run your Android apps -- @@ -181,9 +212,13 @@ To run local unit tests in your Gradle project from Android Studio:

  1. In the Project window, right click on the project and synchronize your project.
  2. -
  3. Open the Build Variants window by clicking the left-hand tab, then change the -test artifact to Unit Tests. + +
  4. In the Project window, drill down to your unit test class or method, then right-click and run it. To run all tests in the unit test directory, select the directory then right-click and press Run tests. @@ -225,16 +260,20 @@ android {

    To run your instrumented tests in Android Studio:

    -
      -
    1. Open the Build Variants window by clicking the left-hand tab, then set the -test artifact to Android Instrumentation Tests. +
        + +
      • In the Project window, drill down to your instrumented test class or method, then right-click and run it using the Android Test configuration. To run all tests in the instrumented test directory, select the directory then right-click and press Run tests.
      • -
    +

    Android Studio displays the results of the instrumented test execution in the Run window.