Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6468267
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T05:52:26+00:00 2026-05-25T05:52:26+00:00

If I write a custom Shadow for my Activity, and registering it with RobolectricTestRunner,

  • 0

If I write a custom Shadow for my Activity, and registering it with RobolectricTestRunner, will the framework intercept the Activity with my custom Shadow whenever it’s started?

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T05:52:26+00:00Added an answer on May 25, 2026 at 5:52 am

    The short answer is no.

    Robolectric is selective about what classes it intercepts and instruments. At the time of this writing, the only classes that will be instrumented must have a fully qualified classname match one of these selectors:

    android.* 
    com.google.android.maps.* 
    org.apache.http.impl.client.DefaultRequestDirector
    

    The whole reason for Robolectric’s existence is that the classes provided in the Android SDK jar throw exceptions when invoked in a JVM (i.e. not on an emulator or device). Your application’s Activity has source that is not ‘hostile’ (it probably does not throw exceptions when the methods or constructors are invoked). Robolectric’s intended purpose is to allow you to put your application’s code under test, which would otherwise not be possible due to the way the SDK is written. Some of the other reasons why Robolectric was created were:

    • The SDK does not always have methods that would allow you to query the state of the Android objects manipulated by your application’s code. Shadows can be written to provide access to this state.
    • Many of the classes and methods in the Android SDK are final and/or private or protected, making it difficult to create the dependencies needed by your application code that would otherwise be available to your application code.

    The code could clearly be changed to shadow any class. There has been talk in the past about extracting the shadowing features into a standalone library, to assist writing tests using some other test-hostile api.

    Why do you want to shadow your Activity?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to write a custom function that will let me retrieve a cell
Is it necessary or advantageous to write custom connection pooling code when developing applications
I want to write a custom view engine that returns custom text (like coma
How can I write a custom IEnumerator<T> implementation which needs to maintain some state
I want to write a custom validator which doesn't do anything before the user
I wanted to write a Custom Control that would show a family tree... so
I'm trying to write a custom WPF ValidationRule to enforce that a certain property
I am trying to write a custom tag. I can write attributes; however, I'm
I'm looking to write a custom touchpad driver for my laptop, as its support
I'm trying to write a custom rendering template for use in the DisplayForm of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.