Thursday, May 23, 2013

Configuring Robolectric 2.0

In Robolectric 1.x, it was necessary to extend RobolectricTestRunner if you wanted to configure things differently.

From 2.0 on, most configuration can be accomplished using either the @Config annotation or by adding a special file on your classpath.

You can add the @Config annotation to individual test methods, or entire test classes.

If you'd like to apply a configuration to your entire project, create a file called "", and place it on your classpath. If you're using maven, you could put it in src/test/resources.


public void shouldDisplayThingsInFrench() {

Configurable values currently include which manifest to use, the SDK level and qualifiers to report, and the list of additional shadows to enable. See the @Config annotation documentation for details.

Also, remember that Robolectric will now look for a test version of your Application class, where you can do additional configuration which used to require subclassing RobolectricTestRunner.


  1. Thanks for providing this blog re configuration. I've been having trouble with the migration from 1.x to 2.x.

    Please provide a custom manifest configuration example. The documentation says "Robolectric will look relative to the current directory." What is the current directory from which I should specify the manifest file (how do I know where it is starting from)? Do I need to include the text "AndroidManifest.xml?"

  2. The approach that ended up working for me was creating a configuration file at the path specified above with this content:


    I'm guessing the standard configuration doesn't work for me because of my project structure:

    - (standard Android project structure here)

    1. I am trying to use this approach and not sure if I need to create a file with exactly "" name and where to put it in my project. Right now I have it placed in my src directory where all my test cases reside. Also, do I need to add this file to my ?

  3. So, if I understood it correctly a shadow class should be annotated with

    @Config(shadows = ShadowYourClass.class)?

  4. For my class say Log, I created a Shadow class "ShadowLog"

    public static class ShadowLog {
    public static int i(java.lang.String tag, java.lang.String msg) {
    System.err.println("[" + tag + "] " + msg);
    return 0;

    Now should I just say @Config(shadows = ShadowLog.class). How does Robolectric figures out which shadow class to call when I say

    Log.i("LogTest", "log message")

  5. You can take a look at It looks like shadowed objects are not instrumented so in your example method call will not be redirected to the shadow object

  6. This comment has been removed by the author.

  7. Add the annotation @Config(manifest="../Android_Project_Under_Test/AndroidManifest.xml") in your Test class or create a file in test directory with following information

  8. I'm writing a custom shadow for GooglePlayServicesUtil, it contains static state that needs to be cleared up at the end of each test. I don't see a logical hook to provide this. I see that Robolectric.reset() is called from deep within ParallelUniverse but no natural way to provide automatic resetting of Shadows.... how about a @Reset annotation that if present on a shadow will automatically be called from here?

  9. Im getting these warnings while unittesting using robolectric about missing AndroidManifest. I understand the configuration change i need to make here, but what if testing a library that doesn't have AndroidManifest.xml ?

  10. Nice post! That's extraordinarily well explained and articulated notably favourable circumstances to hosting trade. currently am being an regular reader of your blogs. Thanks most for extraordinary assortment, keep writing.
    Thanks and cheers!


  12. Thanks for sharing good blog post. I really appreciate your post and you explain each and every point very well. Fashion bloggers in India

  13. These cards are taking over New York
    smart carts
    whats your take??

  14. What an amazing blog you have here Cocaine for Sale thank you for sharing this real good content buy colombian cocaine online will like to also say we have an amazing blog too if you will love to take a look buy peruvian cocaine online thanks for your time to check on our blog. Today cocainehydrochloride is one of the world-leading buy cocaine online manufacturers in the USA . for you to order cocaine online , there is a variety of cocaine websites you can purchase and have it delivered Worldwide . And Yes, you can buy crack cocaine online illegal drugs on the Internet, and it's a lot safer

  15. What a good blog you have here on how to buy Vyvanse online medication. There are many order Vyvanse online
    pharmacy websites that operate legally such as buy adderall XR online and offer convenience, privacy, and safeguards for purchasing buy oxycodone online medications. Also, these medicines may not have been stored properly . So always look out Buy Keifeitropin 140iu Online for details

  16. Xanax belongs to the benzodiazepines drug, which is using to address anxiety, panic disorder, and stress by stimulating the disturbed and unbalanced chemicals in the brain. Xanax offers calming effects in the brain to enhance the productivity evaluator's consultation and guidelines. Buy Xanax online

    buy xanax online

  17. Oxycontin may be a brand of Oxycodone, this is often the controlled-release Oxycodone tablets, intended to be taken every 12 hours. Oxycodone may be a semi-synthetic opioid synthesized from thebaine, an opioid alkaloid found in the Persian poppy, and one among the various alkaloids found within the Papaver somniferous. buy oxycontin online

    buy oxycodone online

  18. Adderall Online is being used under the observation of health experts to address ADHD and narcolepsy without causing any future health issues. Therefore, it works to promote a healthy and progressive mindset by reducing the impact of aggression, stress, and anger. and the formula of Adderall is Adderall online

    buy adderall online

  19. Oxycontin may be a brand of Oxycodone, this is often the controlled-release Oxycodone tablets, intended to be taken every 12 hours. Oxycodone may be a semi-synthetic opioid synthesized from thebaine, an opioid alkaloid found in the Persian poppy, and one among the various alkaloids found within the Papaver somniferous. buy oxycontin online

    buy oxycontin online

  20. Norco may be a powerful prescription pain drug that comprises an opioid (narcotic) that’s utilized to regulate pain severe sufficient to wish an opioid analgesic, while other pain therapies like non-opioid ache medicines don’t manage your illness well adequately, otherwise you cannot bear them. Buy Norco online

    buy norco online

  21. This drug helps in relieving moderate to severe pain. Vicodin contains a narcotic analgesic (hydrocodone) and a non-opioid pain reliever (acetaminophen). Hydrocodone helps the brain to change how your body feels and responds to pain. Buy Vicodin online

    buy vicodin online

  22. This drug helps in relieving moderate to severe pain. Vicodin contains a narcotic analgesic (hydrocodone) and a non-opioid pain reliever (acetaminophen). Hydrocodone helps the brain to change how your body feels and responds to pain. Buy Vicodin online

    buy vicodin online

  23. Its always nice and i feel honored reading your Blog . Your Blogs always based on all basic concepts which anyone can understand so easily and relate to Pleasure to read your Blogs Sir.

    golden retriever puppies for sale near me
    dachshund puppies for sale near me
    golden retriever puppies for sale in pa

  24. A great and awesome write up. An all time relevant article. We are THE RESEARCH CHEMICAL SUPPLIERS(RCS). We Supply top quality Stimulants,
    Depressants, Dissociative, Opioids, Cannabinoids and Pills from china. Safe and discrete delivery. 100% product quality guarantee.
    Place an order today and benefit from our discount offer visit:

  25. köp ketamin
    comprare la ketamina
    ketamint vásárolni
    kupiti ketamin
    Ketamin kaufen
    comprar cetamina
    pirkti ketamino
    osta ketamiini
    osta ketamiini veebis
    pirkti ketamino internete
    comprar cetamina online
    kup ketaminę online
    Ketamin online kaufen
    comprar cetamina online
    купить кетамин онлайн
    kjøp ketamin online
    köp ketamin online
    buy online ketamine
    buy ketamine
    order ketamine online
    ut ketamine online
    beställ ketamin online
    bestill ketamin online
    заказать кетамин онлайн
    Ketamin online bestellen
    online ketamine bestellen
    pedir ketamina en línea

    call/text/<<<<<<<< +1(505)257-5355

  26. i have never been through such an amazing article like this. frosties-runtz-strain this so amazing keep up.

  27. french bulldog have become the most wanted breed of dogs. everyone want to have this breed as their pet. where-to-buy-french-bulldog thanks for giving me this opportunity to place a comment on your blog.

  28. Ajord is an online exclusive store selling high quality traditional wet shaving products and Shaving Gifts. We are proud to offer a wide selection of the most beautiful, handcrafted Shaving razors, Best shaving brush, shaving sets, Shaving Kits for men and other grooming accessories.

  29. I intended to post you a bit of observation so as to thank you so much as before regarding the magnificent pointers you’ve provided here. It’s strangely open-handed with you to offer freely exactly what a few people would have distributed as an e book in order to make some dough for themselves, primarily considering the fact that you might well have tried it in case you decided. Those smart ideas in addition acted like a easy way to fully grasp that other people have the identical eagerness just like my personal own to grasp more in terms of this problem. I think there are lots of more pleasurable times ahead for individuals who looked over your website.

    would like to show my appreciation to the writer for rescuing me from this type of situation. After looking through the the net and seeing methods which were not pleasant, I figured my life was over. Living minus the answers to the problems you’ve sorted out by way of your entire short article is a crucial case, and those that might have adversely affected my entire career if I hadn’t come across your web site. Your actual capability and kindness in maneuvering all the pieces was vital. I don’t know what I would have done if I had not come upon such a stuff like this. I can at this time look ahead to my future. Thanks for your time very much for this high quality and results-oriented guide. I won’t hesitate to refer your site to anyone who requires counselling about this issue.

    My wife and i ended up being so fortunate that Jordan managed to deal with his inquiry out of the precious recommendations he was given out of the blog. It’s not at all simplistic just to find yourself giving away tactics which often a number of people have been trying to sell. And we realize we’ve got the writer to be grateful to because of that. All of the explanations you made, the easy website menu, the friendships your site help engender – it’s got most fabulous, and it’s really aiding our son in addition to the family understand the topic is enjoyable, and that’s really pressing. Thank you for the whole lot!

  30. So informative, thanks to author. Don't you think it's worth posting these thoughts on Instagram? After all, this social network is now very popular. By the way, I advise you to use in order to quickly increase the number of followers and promote your account to the top.


  31. Nice & Informative Blog ! We offer welcome to Mila bulldogs. Check it out!...
    puppies for sale near me
    British bulldog puppies for sale
    where to buy

    Totally loved your article. Looking forward to see more more from you. Meanwhile feel free to surf through my website while i give your blog a read.
    welcome to Newsome frenchies
    where to buy french bulldog puppies
    frenchies bulldog puppies
    in Australia

  32. Hii,
    This is great and awsome post for me. i loved to read your blog. it's really-really amazing. thanks for inspired me by your blog.
    [url=]Buy Online Pure & Natural Essential Oils[/url]
    [url=]Buy Body Massage Essential Oil Online[/url]
    [url=]Buy Hair Essential Oil Online Lowest Price[/url]
    [url=]Buy Skin Essential Oil Online For Men/Women[/url]

  33. Great content and thanks for sharing with us. Do you want to know how to unblock url on facebook

  34. Sumadhura Folium is a new apartment project launched by Sumadhura Properties Pvt. Ltd. There are 2 & 3 BHK plots for sale in Whitefield, Bengaluru. People are grabbing their dream homes from Sumadhura Folium because of the Pre Launch Offers and the trust on the Sumadhura developer and Builders. website;

  35. pure Crack Cocaine Online 98%

    Cocaine Online Vendor, Best Cocaine Online Vendor, Fishscale cocaine online shop, where to buy Fishscale cocaine, blow drug, Bolivian Cocaine Canada, Bolivian Cocaine for sale, Bolivian Cocaine Online, Buy Peruvian Pink Cocaine, cocaina no flour, cocaine for sale, How can I buy Peruvian Cocaine, How to buy Peruvian Cocaine, Order peruvian cocaine, order pure cocaine online, Peruvian Cocaine buy, Peruvian Cocaine buy online, Peruvian cocaine for sale, Peruvian flake, peruvian pink cocaine, pink cocaine, Pink Cocaine for sale online, pink peruvian coke, powder cocaine, Powder Cocaine for sale online, Purchase Powder Cocaine Online, Pure Bolivian Cocaine Online, strawberry cocaine, Where can I buy Peruvian Cocaine, Where to buy Peruvian Cocaine, Where to Buy Peruvian Pink Cocaine online, Where to buy real Peruvian Pink Cocaine Online

    Wholesale Cocaine Online Vendor
    Wholesale Bolivian Cocaine Online Vendor
    Wholesale Uncut Cocaine Online Vendor
    Wholesale Colombian Cocaine Online Vendor
    Wholesale Black, Brown & china Heroin Online Vendor
    Wholesale Kilocaine Powder Online Vendor
    Wholesale Peruvian Cocaine Online Vendor
    Wholesale Volkswagen Cocaine Online Vendor
    whatsApp number : +15024936152

  36. A decent deciding element for surveying pot fixation is in the event that you are fostering a resilience to the substance.BC Bud Online


  37. Are you looking for the best Cocaine online, Colombian cocaine-, Mexican cocaine, Crack cocaine, Bolivia cocaine, Heroin, Black-tar-heroin online, and concentrates order from dispensary center an online dispensary that has unique and exotic strains which are highly recommended for medical use only. Choose from the wide variety of Indica, Sativa, and Hybrid medicinal dispensary in store.