Test project setup in Android Studio – Updated

Android Studio IDE is gradually improving. One of these improvements is the management of tests cases in the Android projects. In this old post: Test project setup in Android Studio, I explained how to prepare your Android project to run test cases.
In the last versions of Android Studio, v0.8 and above, this process has been simplified. When a new project is created, a test package is automatically added. Tests will be saved in this package under the folder: /src/androidTest/java/<your_package>. Notice that the classes under test and the test classes are in the same package.
The project structure now looks like:
Project structure
Add your test classes in the test folder. To execute them, click on the package using the right mouse button and select the Run ‘Tests in <your_package>’ command. You can also run only one test class if you directly select it instead of the whole package.
Run Tests

Share Button

Leave a Reply

Your email address will not be published.

Time limit is exhausted. Please reload the CAPTCHA.