Loading docs/html/images/training/testartifactcombined.png 0 → 100644 +85.6 KiB Loading image diff... docs/html/images/training/testartifactseparate.png 0 → 100644 +102 KiB Loading image diff... docs/html/training/testing/start/index.jd +45 −6 Original line number Original line Diff line number Diff line Loading @@ -162,6 +162,37 @@ dependencies { } } </pre> </pre> <h3 id="testartifacts">Work With Test Artifacts</h3> <p>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.</p> <p>The figure shows what your project looks like with both test artifacts enabled. Notice the shading of both test artifacts.</p> <!-- Commenting out for now, but leaving it in case we need to add it back. <img src="{@docRoot}images/training/testartifactseparate.png" style="float:left;width:250px;margin-right:20px" /> --> <img src="{@docRoot}images/training/testartifactcombined.png" style="float:left;width:250px" /> <!-- Commenting out for now, but leaving it in case we need to add it back. <p> By default, both test artifacts are enabled in Android Studio. To enable just one, deselect <strong>Enable all test artifacts</strong> in your preferences: </p> <ol> <li>Select <strong>Android Studio</strong> > <strong>Preferences</strong> > <strong>Build, Execution, Deployment</strong> > <strong>Build Tools</strong> > <strong>Gradle</strong> > <strong>Experimental</strong>.</li> <li>Deselect the test artifacts option.</li> <li>Click <strong>OK</strong>.</li> </ol> --> <h2 id="build">Build and Run Your Tests</h2> <h2 id="build">Build and Run Your Tests</h2> <p>You can run build and run your tests in a similar way to how you run your Android apps -- <p>You can run build and run your tests in a similar way to how you run your Android apps -- Loading @@ -181,9 +212,13 @@ To run local unit tests in your Gradle project from Android Studio: <ol> <ol> <li>In the <strong>Project</strong> window, right click on the project and synchronize your project. <li>In the <strong>Project</strong> window, right click on the project and synchronize your project. </li> </li> <li>Open the <strong>Build Variants</strong> window by clicking the left-hand tab, then change the <!-- test artifact to <em>Unit Tests</em>. <li>If you enabled one test artifact only, open the <strong>Build Variants</strong> window by clicking the left-hand tab, then change the test artifact to <em>Unit Tests</em>. </li> </li> --> <li>In the <strong>Project</strong> window, drill down to your unit test class or method, <li>In the <strong>Project</strong> 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 then right-click and run it. To run all tests in the unit test directory, select the directory then right-click and press <strong>Run tests</strong>. right-click and press <strong>Run tests</strong>. Loading Loading @@ -225,16 +260,20 @@ android { </pre> </pre> <p>To run your instrumented tests in Android Studio:</p> <p>To run your instrumented tests in Android Studio:</p> <ol> <ul> <li>Open the <strong>Build Variants</strong> window by clicking the left-hand tab, then set the <!-- test artifact to <em>Android Instrumentation Tests</em>. <li>If you enabled one test artifact only, open the <strong>Build Variants</strong> window by clicking the left-hand tab, then set the test artifact to <em>Android Instrumentation Tests</em>. </li> </li> --> <li>In the <strong>Project</strong> window, drill down to your instrumented test class or method, <li>In the <strong>Project</strong> 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 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 instrumented test directory, select the directory then right-click and press <strong>Run tests</strong>. <strong>Run tests</strong>. </li> </li> </ol> </ul> <p>Android Studio displays the results of the instrumented test execution in the <p>Android Studio displays the results of the instrumented test execution in the <strong>Run</strong> window.</p> <strong>Run</strong> window.</p> Loading Loading
docs/html/training/testing/start/index.jd +45 −6 Original line number Original line Diff line number Diff line Loading @@ -162,6 +162,37 @@ dependencies { } } </pre> </pre> <h3 id="testartifacts">Work With Test Artifacts</h3> <p>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.</p> <p>The figure shows what your project looks like with both test artifacts enabled. Notice the shading of both test artifacts.</p> <!-- Commenting out for now, but leaving it in case we need to add it back. <img src="{@docRoot}images/training/testartifactseparate.png" style="float:left;width:250px;margin-right:20px" /> --> <img src="{@docRoot}images/training/testartifactcombined.png" style="float:left;width:250px" /> <!-- Commenting out for now, but leaving it in case we need to add it back. <p> By default, both test artifacts are enabled in Android Studio. To enable just one, deselect <strong>Enable all test artifacts</strong> in your preferences: </p> <ol> <li>Select <strong>Android Studio</strong> > <strong>Preferences</strong> > <strong>Build, Execution, Deployment</strong> > <strong>Build Tools</strong> > <strong>Gradle</strong> > <strong>Experimental</strong>.</li> <li>Deselect the test artifacts option.</li> <li>Click <strong>OK</strong>.</li> </ol> --> <h2 id="build">Build and Run Your Tests</h2> <h2 id="build">Build and Run Your Tests</h2> <p>You can run build and run your tests in a similar way to how you run your Android apps -- <p>You can run build and run your tests in a similar way to how you run your Android apps -- Loading @@ -181,9 +212,13 @@ To run local unit tests in your Gradle project from Android Studio: <ol> <ol> <li>In the <strong>Project</strong> window, right click on the project and synchronize your project. <li>In the <strong>Project</strong> window, right click on the project and synchronize your project. </li> </li> <li>Open the <strong>Build Variants</strong> window by clicking the left-hand tab, then change the <!-- test artifact to <em>Unit Tests</em>. <li>If you enabled one test artifact only, open the <strong>Build Variants</strong> window by clicking the left-hand tab, then change the test artifact to <em>Unit Tests</em>. </li> </li> --> <li>In the <strong>Project</strong> window, drill down to your unit test class or method, <li>In the <strong>Project</strong> 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 then right-click and run it. To run all tests in the unit test directory, select the directory then right-click and press <strong>Run tests</strong>. right-click and press <strong>Run tests</strong>. Loading Loading @@ -225,16 +260,20 @@ android { </pre> </pre> <p>To run your instrumented tests in Android Studio:</p> <p>To run your instrumented tests in Android Studio:</p> <ol> <ul> <li>Open the <strong>Build Variants</strong> window by clicking the left-hand tab, then set the <!-- test artifact to <em>Android Instrumentation Tests</em>. <li>If you enabled one test artifact only, open the <strong>Build Variants</strong> window by clicking the left-hand tab, then set the test artifact to <em>Android Instrumentation Tests</em>. </li> </li> --> <li>In the <strong>Project</strong> window, drill down to your instrumented test class or method, <li>In the <strong>Project</strong> 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 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 instrumented test directory, select the directory then right-click and press <strong>Run tests</strong>. <strong>Run tests</strong>. </li> </li> </ol> </ul> <p>Android Studio displays the results of the instrumented test execution in the <p>Android Studio displays the results of the instrumented test execution in the <strong>Run</strong> window.</p> <strong>Run</strong> window.</p> Loading