Android Testing Support Library 1.0 is here!


We’re happy to announce the model 1.0 launch of the Android Testing Support
Library (ATSL).

ATSL model 1.0 is a big replace to our present checking out APIs and springs with
a lot of new options, advanced efficiency, balance, and insect fixes. It
supplies complete API parity with the now deprecated Android platform checking out APIs.
This launch additionally provides numerous options that we mentioned in our Google I/O 2017 communicate,
reminiscent of local strengthen for Multiprocess
Espresso
and the Android
Test Orchestrator
.

We also are glad to announce that, beginning with model 1.0, we are
distributing releases on Google’s Maven repository, which makes it so much more straightforward
to make use of ATSL on your builds. To be informed extra about the use of this repository, see the
getting began with the Google Maven repository information. Note that we are no
longer tying long run updates to the checking out infrastructure with platform updates.
If you haven’t but upgraded your exams to ATSL, this is a very good time.

Finally, we need to announce a large replace to our Android checking out documentation.
We’ve migrated our previous checking out documentation from our GitHub
website
to builders.android.com/checking out.
All the checking out documentation now seems in one position, making it even
more straightforward to discover ways to write and execute exams on Android.

Let’s transfer directly to the thrill a part of this publish, an summary of latest APIs and gear
that we are offering on this launch.

Espresso
Improvements

Espresso three.zero.zero comes with wonderful new options and advanced
total efficiency. Some of the highlights come with: Multiprocess Espresso,
Idling Registry and new Idling Resources. Let’s dive in and feature a extra detailed
take a look at those new options:

Multiprocess Espresso

Starting with Android
O
, the platform comprises strengthen for instrumenting exams out of doors of your
app’s default procedure. (Prior to Android O, you must most effective examine towards app
elements on your app’s default procedure.) Multiprocess Espresso makes this
strengthen conceivable. It permits you to seamlessly examine your app’s UI interactions
that move procedure barriers whilst nonetheless keeping up Espresso’s synchronization
promises.

The excellent information is that Espresso does the entire paintings; you wouldn’t have to switch
the rest for setups with UI in a couple of processes. You can stay writing your
Espresso exams like you might for unmarried procedure apps, and Espresso
mechanically handles the method IPC and synchronization between processes.

The following diagram displays how a couple of circumstances of Espresso keep up a correspondence with
every different:

If you need to be told extra about Multiprocess Espresso and the right way to use it, please
check out our documentation
and our Multiprocess
sample
.

Idling Registry

Some apps use construct flavors in Gradle or a dependency injection framework, like
Dagger, to generate examine construct configurations that check in idling assets.
Others merely reveal the idling useful resource thru their actions. The drawback
with these types of approaches is that they upload complexity on your building
workflow, and a few of them even wreck encapsulation. With the most recent launch of
Espresso, we now have made it more straightforward to check in idling assets from inside of your app
code by means of introducing the brand new IdlingRegistry API.
IdlingRegistry is a light-weight registry that does not carry within the
complete Espresso library, so you’ll be able to extra simply check in assets out of your
software code. When combining this API with Multiprocess Espresso, you’ll be able to
check in idling assets from any procedure inside of your software code.

Registration from the Espresso magnificence is now deprecated.

Idling Resources

Writing customized idling assets will also be time eating, so Espresso three.zero.zero now
comes with extra idling assets out of the field to synchronize your threads. The
new assets come with: IdlingThreadPoolExecutor and
IdlingScheduledThreadPoolExecutor. There will likely be extra to return!

To make the most of the brand new idling useful resource, upload those new dependencies on your
construct.gradle record:

  androidTestAssemble "com.android.support.test.espresso.idling:idling-concurrent:3.0.0"

Additionally, CountingIdlingUseful resource,
which was once prior to now deprecated in Espresso contrib, has been got rid of with this
launch. Therefore, you want to replace your exams to make use of the brand new CountingIdlingUseful resource
bundle that is positioned in Espresso idling useful resource. For the overall migration
main points, check with our release
notes
.

SupplierTestRule

When you examine ContentProvider
items, you’ll be able to now use SupplierTestRule
as a substitute of SupplierTestCase2.
SupplierTestRule provides an more straightforward solution to paintings with different examine regulations
these days to be had for AndroidJUnit4.

SupplierTestRule
comprises APIs for initialization, in addition to instructions to run towards a ContentProvider
beneath examine. If your ContentProvider is based totally off of a SQLite
database, you’ll be able to use the SupplierTestRule instructions for surroundings the
database record and initialization instructions.

To be informed extra, see the SupplierTestRule
documentation.

Grant Permission
Rule

Android M (API degree 23) permits apps to request permissions at runtime. However,
the dialogs that request runtime permissions position exams in a state the place they
can’t proceed, inflicting them to fail. By the use of GrantPermissionRule,
you’ll be able to skip the conversation popups altogether and simulate a consumer granting a runtime
permission to your app.

Android Test
Orchestrator

Typically, AndroidJUnitRunner runs all exams in the similar instrumentation
procedure, which will reason numerous issues. For instance, exams proportion their
state in reminiscence, and if one examine crashes, it prevents the rest of the examine
suite from operating.

Although it is conceivable to isolate exams by means of issuing sequential adb
instructions, this procedure provides host-side processing load. By the use of the brand new Android
Test Orchestrator as a substitute, you’ll be able to reach examine isolation solely at the
instrument, as proven on this diagram:

Be mindful that in case your exams require shared state to move, the
orchestrator reasons them to fail. This habits is by means of design. As of this publish,
Android Test Orchestrator is in beta and is to be had to be used by the use of the command
line. We have integrations deliberate for Firebase Test Lab and Android Studio,
coming quickly.

For additional info, see the Android
Testing Orchestrator developer guide
.

AndroidJUnitRunner

AndroidJUnitRunner now comprises numerous further options:

  • You can use JUnitParams.
  • You can configure magnificence loaders and customized JUnit examine filters the use of the
    runner arguments

Sometimes you need to check an process that you simply create and configure at the fly
as a part of your examine workflow. Now, you’ll be able to configure MonitoringInstrumentation
(and by means of extension, AndroidJUnitRunner)
the use of an InterceptingActivityFactory.
You can create your process beneath examine with a test-specific configuration
with no need to depend on compile-time injection.

This assessment highlights most effective probably the most most important adjustments that we now have
made to ATSL. They are many extra adjustments which might be price exploring. For the overall
launch main points, check with our release
notes
.

Last however now not least, we need to thank the entire builders who contributed options
to this launch. We additionally need to thank the Android checking out mavens at the cell
engineering groups at American Express, Slack and GDE Chiu-Ki Chan for
taking part with us and offering precious comments at the pre-release model
of Android Testing Support Library.

Happy checking out from the ATSL crew!

We’re happy to announce the model 1.0 launch of the Android Testing Support
Library (ATSL).

ATSL model 1.0 is a big replace to our present checking out APIs and springs with
a lot of new options, advanced efficiency, balance, and insect fixes. It
supplies complete API parity with the now deprecated Android platform checking out APIs.
This launch additionally provides numerous options that we mentioned in our Google I/O 2017 communicate,
reminiscent of local strengthen for Multiprocess
Espresso
and the Android
Test Orchestrator
.

We also are glad to announce that, beginning with model 1.0, we are
distributing releases on Google’s Maven repository, which makes it so much more straightforward
to make use of ATSL on your builds. To be informed extra about the use of this repository, see the
getting began with the Google Maven repository information. Note that we are no
longer tying long run updates to the checking out infrastructure with platform updates.
If you haven’t but upgraded your exams to ATSL, this is a very good time.

Finally, we need to announce a large replace to our Android checking out documentation.
We’ve migrated our previous checking out documentation from our GitHub
website
to builders.android.com/checking out.
All the checking out documentation now seems in one position, making it even
more straightforward to discover ways to write and execute exams on Android.

Let’s transfer directly to the thrill a part of this publish, an summary of latest APIs and gear
that we are offering on this launch.

Espresso
Improvements

Espresso three.zero.zero comes with wonderful new options and advanced
total efficiency. Some of the highlights come with: Multiprocess Espresso,
Idling Registry and new Idling Resources. Let’s dive in and feature a extra detailed
take a look at those new options:

Multiprocess Espresso

Starting with Android
O
, the platform comprises strengthen for instrumenting exams out of doors of your
app’s default procedure. (Prior to Android O, you must most effective examine towards app
elements on your app’s default procedure.) Multiprocess Espresso makes this
strengthen conceivable. It permits you to seamlessly examine your app’s UI interactions
that move procedure barriers whilst nonetheless keeping up Espresso’s synchronization
promises.

The excellent information is that Espresso does the entire paintings; you wouldn’t have to switch
the rest for setups with UI in a couple of processes. You can stay writing your
Espresso exams like you might for unmarried procedure apps, and Espresso
mechanically handles the method IPC and synchronization between processes.

The following diagram displays how a couple of circumstances of Espresso keep up a correspondence with
every different:

If you need to be told extra about Multiprocess Espresso and the right way to use it, please
check out our documentation
and our Multiprocess
sample
.

Idling Registry

Some apps use construct flavors in Gradle or a dependency injection framework, like
Dagger, to generate examine construct configurations that check in idling assets.
Others merely reveal the idling useful resource thru their actions. The drawback
with these types of approaches is that they upload complexity on your building
workflow, and a few of them even wreck encapsulation. With the most recent launch of
Espresso, we now have made it more straightforward to check in idling assets from inside of your app
code by means of introducing the brand new IdlingRegistry API.
IdlingRegistry is a light-weight registry that does not carry within the
complete Espresso library, so you’ll be able to extra simply check in assets out of your
software code. When combining this API with Multiprocess Espresso, you’ll be able to
check in idling assets from any procedure inside of your software code.

Registration from the Espresso magnificence is now deprecated.

Idling Resources

Writing customized idling assets will also be time eating, so Espresso three.zero.zero now
comes with extra idling assets out of the field to synchronize your threads. The
new assets come with: IdlingThreadPoolExecutor and
IdlingScheduledThreadPoolExecutor. There will likely be extra to return!

To make the most of the brand new idling useful resource, upload those new dependencies on your
construct.gradle record:

  androidTestAssemble "com.android.support.test.espresso.idling:idling-concurrent:3.0.0"

Additionally, CountingIdlingUseful resource,
which was once prior to now deprecated in Espresso contrib, has been got rid of with this
launch. Therefore, you want to replace your exams to make use of the brand new CountingIdlingUseful resource
bundle that is positioned in Espresso idling useful resource. For the overall migration
main points, check with our release
notes
.

SupplierTestRule

When you examine ContentProvider
items, you’ll be able to now use SupplierTestRule
as a substitute of SupplierTestCase2.
SupplierTestRule provides an more straightforward solution to paintings with different examine regulations
these days to be had for AndroidJUnit4.

SupplierTestRule
comprises APIs for initialization, in addition to instructions to run towards a ContentProvider
beneath examine. If your ContentProvider is based totally off of a SQLite
database, you’ll be able to use the SupplierTestRule instructions for surroundings the
database record and initialization instructions.

To be informed extra, see the SupplierTestRule
documentation.

Grant Permission
Rule

Android M (API degree 23) permits apps to request permissions at runtime. However,
the dialogs that request runtime permissions position exams in a state the place they
can’t proceed, inflicting them to fail. By the use of GrantPermissionRule,
you’ll be able to skip the conversation popups altogether and simulate a consumer granting a runtime
permission to your app.

Android Test
Orchestrator

Typically, AndroidJUnitRunner runs all exams in the similar instrumentation
procedure, which will reason numerous issues. For instance, exams proportion their
state in reminiscence, and if one examine crashes, it prevents the rest of the examine
suite from operating.

Although it is conceivable to isolate exams by means of issuing sequential adb
instructions, this procedure provides host-side processing load. By the use of the brand new Android
Test Orchestrator as a substitute, you’ll be able to reach examine isolation solely at the
instrument, as proven on this diagram:

Be mindful that in case your exams require shared state to move, the
orchestrator reasons them to fail. This habits is by means of design. As of this publish,
Android Test Orchestrator is in beta and is to be had to be used by the use of the command
line. We have integrations deliberate for Firebase Test Lab and Android Studio,
coming quickly.

For additional info, see the Android
Testing Orchestrator developer guide
.

AndroidJUnitRunner

AndroidJUnitRunner now comprises numerous further options:

  • You can use JUnitParams.
  • You can configure magnificence loaders and customized JUnit examine filters the use of the
    runner arguments

Sometimes you need to check an process that you simply create and configure at the fly
as a part of your examine workflow. Now, you’ll be able to configure MonitoringInstrumentation
(and by means of extension, AndroidJUnitRunner)
the use of an InterceptingActivityFactory.
You can create your process beneath examine with a test-specific configuration
with no need to depend on compile-time injection.

This assessment highlights most effective probably the most most important adjustments that we now have
made to ATSL. They are many extra adjustments which might be price exploring. For the overall
launch main points, check with our release
notes
.

Last however now not least, we need to thank the entire builders who contributed options
to this launch. We additionally need to thank the Android checking out mavens at the cell
engineering groups at American Express, Slack and GDE Chiu-Ki Chan for
taking part with us and offering precious comments at the pre-release model
of Android Testing Support Library.

Happy checking out from the ATSL crew!



Source link

Reply