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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T17:48:38+00:00 2026-06-14T17:48:38+00:00

I have downloaded this code from developer.android public class SpinnerTestActivity extends ActivityInstrumentationTestCase2<SpinnerActivity> { private

  • 0

I have downloaded this code from developer.android

public class SpinnerTestActivity extends
        ActivityInstrumentationTestCase2<SpinnerActivity> {

    private SpinnerActivity mActivity;
    private Spinner mSpinner;
    private SpinnerAdapter mPlanetData;
    public static final int ADAPTER_COUNT = 9;
    public static final int INITIAL_POSITION = 0;
    public static final int TEST_POSITION = 5;

    private String mSelection;
    private int mPos;

    public SpinnerTestActivity() {
        super("com.android.example.spinner", SpinnerActivity.class);
    } // end of SpinnerActivityTest constructor definition

    @Override
    protected void setUp() throws Exception {
        super.setUp();

        setActivityInitialTouchMode(false);

        mActivity = getActivity();

        mSpinner = (Spinner) mActivity
                .findViewById(com.android.example.spinner.R.id.Spinner01);

        mPlanetData = mSpinner.getAdapter();

    } // end of setUp() method definition

    public void testPreConditions() {
        assertTrue(mSpinner.getOnItemSelectedListener() != null);
        assertTrue(mPlanetData != null);
        assertEquals(mPlanetData.getCount(), ADAPTER_COUNT);
    } // end of testPreConditions() method definition

    public void testSpinnerUI() {

        mActivity.runOnUiThread(new Runnable() {
            public void run() {
                mSpinner.requestFocus();
                mSpinner.setSelection(INITIAL_POSITION);
            } // end of run() method definition
        } // end of anonymous Runnable object instantiation
                ); // end of invocation of runOnUiThread
        this.sendKeys(KeyEvent.KEYCODE_DPAD_CENTER);
        for (int i = 1; i <= TEST_POSITION; i++) {
            this.sendKeys(KeyEvent.KEYCODE_DPAD_DOWN);
        } // end of for loop

        this.sendKeys(KeyEvent.KEYCODE_DPAD_CENTER);
        mPos = mSpinner.getSelectedItemPosition();
        mSelection = (String) mSpinner.getItemAtPosition(mPos);
        TextView resultView = (TextView) mActivity
                .findViewById(com.android.example.spinner.R.id.SpinnerResult);

        String resultText = (String) resultView.getText();

        assertEquals(resultText, mSelection);

    }
}

My question is: How the testSpinnerUI is invoked? From where? I have read the junit documentation but cannot figure out.. 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-06-14T17:48:39+00:00Added an answer on June 14, 2026 at 5:48 pm

    Stupid question, though. I found the answer in this blog.

    The lifecycle of a test case is basically this: construction, setUp(), tests run, tearDown(), and destruction. The setUp() method is used to do any general initialization used by all of specific tests. Each test to be run in the test case is implemented as its own method, where the method name begins with “test”. The tearDown() method is then used to uninitialize any resources acquired by the setUp() method.
    Each specific test will have it’s own method beginning with “test” – the “test” method name prefix is case sensitive!

    My initial question was how the test method ran, since no one is calling it. But from the above test each method should sart with test, so as to be identified.

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

Sidebar

Related Questions

I have downloaded the sample code from this site for FTP Client http://www.lysesoft.com/products/andftp/index.html But
I have downloaded the sample code GLPaint from developer.Apple website to draw pictures on
I have downloaded the sample code GLPaint from developer.Apple website to draw pictures on
When I have download sample code from this link and than try to build
I have downloaded the source code and using this logview to view log4net logs.
I have downloaded both samples for the Facebook Developer Kit from Codeplex and Facebook.NET
I have downloaded some code from svn into my system. Now through maven I
Hi I have this code to download images from the server and then to
I have downloaded facebook-java-api-3.0.2-bin from http://code.google.com/p/facebook-java-api/ for connecting to face book.I want to use
I have this code to download a file, but on sourceforge.net sever there is

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.