Creating testing files

Let's write some test cases. To write this code, we need to create new files in the androidTest package. To do this, follow the steps:

  1. Now go to srcandroidTest | java | module_name of the project. Here is a screenshot of this directory:

  1. Create a class named MainActivityTest.kt with @RunWith(AndroidJUnit4::class) annotation. This annotation will link the test and the app features.

Let's create our very first Espresso test:

First of all, we need to connect our MainActivity class. To do this, we will initialize a variable of ActivityTestRule<MainActivity> and it will provide all the functionalities for the MainActivity ...

Get Learn Spring for Android Application Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.