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 5848207
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T12:49:36+00:00 2026-05-22T12:49:36+00:00

In the JavaDoc of ActivityUnitTestCase it says: Do not call from your setUp() method.

  • 0

In the JavaDoc of ActivityUnitTestCase it says:

Do not call from your setUp() method. You must call this method from each of your test methods.

Isn’t putting something in every test method equivalent to putting it in setUp, considering that the whole idea behind that method is to do just that, i.e. executing something before every test?

Also, why are we not allowed to do that? I tried it, and it works just fine.

  • 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-22T12:49:37+00:00Added an answer on May 22, 2026 at 12:49 pm

    It appears that setUp runs with the test project’s class loader, while the actual test methods run with the app under test’s class loader. See, for example, this discussion on the RoboGuice mailing list:

    http://groups.google.com/group/roboguice/browse_thread/thread/2e129f87ead10b10

    Why this is the case, I’m not sure (it seems like a very strange design decision to me). But the upshot is that you can’t access anything in the app under test in your setUp method. Which moves setUp into chocolate teapot territory.

    Note that this restriction does not apply if you’re testing a library project as described here:

    http://www.paulbutcher.com/2010/09/android-library-project-with-tests-step-by-step/

    Because in that case the tests and the code under test are all in a single app.

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

Sidebar

Related Questions

from the javadoc for java.lang.Process : The methods that create processes may not work
I see from the javadoc that the @SuppressWarnings annotation applies to TYPE,FIELD,METHOD,PARAMETER,CONSTRUCTOR,LOCAL_VARIABLE targets. Why
This FileInputStream.available() javadoc says: Returns an estimate of the number of remaining bytes that
The javadoc says: Please note that this class is designed to provide convenience rather
The javadoc for Executors.newSingleThreadScheduledExecutor says ... the returned executor is guaranteed not to be
From JavaDoc : public void validate() Validates this container and all of its subcomponents.
NumberFormat JavaDoc says: Number formats are generally not synchronized. It is recommended to create
From the javadoc of Calendar.before(Object when) : Returns whether this Calendar represents a time
From the JavaDoc, the EXTRA_STREAM parameter when launching an intent needs to be an
Since in log4j javadoc is WARNING: This version of JDBCAppender is very likely to

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.