Migrating to AndroidX

What is AndroidX?
AndroidX is an improved version of the android support libraries that the android team uses to develop, test, package, version and release libraries within the jetpack. AndroidX fully replaces the support library by providing feature parity and new libraries. In addition, AndroidX includes the following features:

  • All packages in AndroidX are in consistent namespace starting with the string AndroidX. The support library packages have been mapped into androidx.* packages. For a full mapping of all the old classes and built artifacts to the new ones.
  • Unlike the support libraries, AndroidX packages are separately maintained and updated. The AndroidX uses strict semantic versioning.
  • All new android development will occur in the AndroidX library. This includes maintenance of the original support library artifacts and introduction of new jetpack components.

Android Jetpack
Android jetpack is a set of components and tools along with architecture guidance designed to help you accelerate your android development. It gives a template to write production ready android code. Jetpack is made up of components in four categories, foundation architecture behaviour and UI. Each component is individually adaptable and build to maintain backwards compatibility. Android architecture components are very modular, so we are allowed to choose what feature sets we want that are compatible to our app.

Espresso is now a part of the AndroidX family
Espresso is a testing framework designed to provide a fluent API for writing concise and reliable UI test. Writing reliable UI test is difficult as user interfaces are asynchronous driven by events, transitions and data loaded from background threats. Coding around that without any help from UI testing framework would require a lot of boilerplate. Espresso takes care of any UI events, so that in most cases you don’t have to worry about any view state transition and implementation details. The basic UI test flow when using Espresso includes:

  • View Matchers: To find view in the current view hierarchy for e.g. to find UI elements like buttons, textbox etc.
  • View Action: To perform action on the view, e.g. to click on a button, double click, scrolling etc.
  • View Assertions: Allows to assert state of a view.

Application of Espresso test recorder

  • Allows us to create effective UI test cases with user interactions.
  • We can capture assertions and interactions without accessing app structure directly which increases execution speed and optimizes test case.
  • Saves time searching for locators and then writing the test cases.
  • It supports multiple assertions making more reliable test cases.

Pcloudy supports androidX instrumentation with Espresso
Now you can write test cases in espresso and test the APIs in pCloudy using androidX Junit instrumentation. Here are the steps for running your Test scripts on multiple android devices:

  • Login over https://device.pcloudy.com with your registered Email ID & Password.
  • To schedule “Espresso” over pCloudy, follow the below mentioned steps-
  • Go to the “Automation” page.
  • Select the Automation tool as “Espresso”.
  • Select “Instrumentation Type” based on your Test Scripts you’ve written.
  • Androidx Espresso Test pCloudy_1
    Note: pCloudy provides support for Instrumentation Type (InstrumentationTestRunner, AndroidJUnitRunner and AndroidXJUnitRunner) for Android.

  • Select the Application APK and Test APK that you must have uploaded in the MY APP/DATA section.
  • Select the single device execution time and assign a name to your test cycle.
  • In the next step, Click on “ADD” to add the device for testing and click on ”
    Next”.
  • Click on “Schedule” to start the test.
  • Espresso Test pCloudy_2

  • Go to your mailbox and open pCloudy Automation Alert mail.
  • Click on the given link “Click to view Report”.
  • Espresso Test pCloudy_3

  • Now you have the result of your scheduled test automation.
  • Espresso Test pCloudy_4

How to migrate to AndroidX?

To migrate from support libraries to AndroidX the Google has provided a refractor tool in Android Studio. Projects can be migrated to AndroidX by clicking on ‘Refractor’ in the menu bar and then clicking on ‘Refactor to AndroidX’. Then it will search for the usage and show the result. To refactor click ‘Do Refactor’.

pCloudy is leading the way in the field of automated mobile testing solutions.

Try our device cloud