It means that this configuration will run all the tests in package.Ĭool! We have created an app project and a test configuration. In configurations dialog, expand Android Tests group and select Tests in ‘’ configuration. If you are curious how the Test Configuration works open Run > Edit Configurations from the main menu. This is how we can switch between running the app and tests.Ĭlick Save ‘Tests ‘’’ Configuration item from the menu to save the test configuration that you just created. We have created configuration for testing and can now use it any time we want to run our tests.Ĭlick the configuration dropdown menu located next to the run button on the toolbar. Switch between App and Test configurations If your Run window is closed click the Run button on the bottom panel or select View > Tool Windows > Run from the main menu. You will see a lot of green colour in the Run tool window.
Enter Greeter in Application Name and in Company Domain.Īccept the default settings on “Target Android Devices” screen with just “Phone and Tablet” option selected.Open Android Studio and create a new project: File > New > New Project.In our test, we’ll just wrap our custom view in a layout. Our MockActivity relies on us providing a layout resource ID, which will then be used to set the Activity’s content view. We’ll create a class in our androidTest directory, and set-up the ActivityTestRule for our MockActivity. Let’s get started: create a project in Android Studio We’re all set-up, now it’s time to finally test our custom view. In this app user enters a name and taps the “Greet” button. It has a text input and a “Greet” button. Please refer to the excellent Building Your First App tutorial from Google.
#ANDROID STUDIO CENTER TESTVIEW HOW TO#
I assume you already knowįor this tutorial you will need to have Android Studio installed and know how to run an app.
#ANDROID STUDIO CENTER TESTVIEW FOR ANDROID#
This tutorial is updated for Android Studio version 2.1. Write tests for basic UI interactions in activity.Create new test configuration and run the tests.Create a new project in Android Studio.