Using Add-On Modules

In order to reduce the number of external dependencies on the application being tested, Robolectric’s shadows are split into various add-on packages. Only shadows for classes provided in the base Android SDK are provided by the main Robolectric module. Additional shadows for things like appcompat or the support library are provided by add-on modules. The table below lists the available add-on shadow packages:

SDK Package Robolectric Add-On Package
com.android.support.support-v4 org.robolectric:shadows-supportv4
com.android.support.multidex org.robolectric:shadows-multidex
com.google.android.gms:play-services org.robolectric:shadows-playservices
org.apache.httpcomponents:httpclient org.robolectric:shadows-httpclient

The above artifact names are in use since Robolectric 3.5+. Robolectric 3.4.x drops shadows- prefix from artifact names. Prior to 3.4, all artifact names are the same as latest, except that shadows-supportv4 and shadow-playservices are shadows-support-v4 and shadow-play-services respectively.

Note that org.robolectric:shadows-supportv4 was deprecated at Robolectric 4.8, and was removed at Robolectric 4.9.

Robolectric
  • Home
  • Setup
    • Getting Started
    • Writing Your First Test
  • User Guide
    • AndroidX Test
    • Configuring Robolectric
    • Device Configuration
    • Using Qualified Resources
    • Using Add-On Modules
    • Best Practices
  • Customizing
    • Build System Integration
    • Customizing the Test Runner
  • Contributing
    • Building Robolectric
    • Contributor Guidelines
    • Shadows
  • Resources
    • GitHub
    • Release Notes
    • Migration Guide
    • Javadoc: 3.8 | 4.0 | 4.1 | 4.2 | 4.3 | 4.4 | 4.5 | 4.6 | 4.7 | 4.8 | 4.9
    • Issues

Recent Posts

GSoC 2022 - ConscryptMode

Sep 6, 2022

My name is Umesh Singh and I was an...

sharedTest pattern: sharing tests and speeding up development

Oct 6, 2021

After Robolectric’s 4.0 release, Robolectric supports...

A memorial tribute for Jonathan Gerrish

Sep 13, 2021

In late August, 2021, we were incredibly saddened to learn...

  • More…

Chrome Extension

See Robolectric documentation inline with Android Developer Documentation.

Contact

  • GitHub Project
  • robolectric@googlegroups.com
  • @Robolectric

©2010-2017. All rights reserved.
Design: HTML5 UP.