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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T00:33:10+00:00 2026-06-02T00:33:10+00:00

public class LoginActivityTest extends ActivityInstrumentationTestCase2<Login> { Login mActivity; private EditText username; private EditText password;

  • 0
public class LoginActivityTest extends ActivityInstrumentationTestCase2<Login> {


        Login mActivity;
        private EditText username;
        private EditText password;

          @SuppressWarnings("deprecation")
        public LoginActivityTest()
          {
              super("com.main.account.Login",Login.class);
          }


          @Override
        protected void setUp() throws Exception {
              super.setUp();
              mActivity = this.getActivity();

              username = (EditText) mActivity.findViewById(R.id.username);
              password = (EditText) mActivity.findViewById(R.id.password);
                      }

          public void testPreconditions() { 
              assertNotNull(username);
              assertNotNull(password);
            }


          public void testText() {
              assertEquals("hello",username.getText());
              assertEquals("hello123", password.getText());
            }

}

Error I get is this:

04-18 16:03:47.132: I/TestRunner(12376): junit.framework.AssertionFailedError: expected:<hello> but was:<>
04-18 16:03:47.132: I/TestRunner(12376):    at junit.framework.Assert.fail(Assert.java:47)
04-18 16:03:47.132: I/TestRunner(12376):    at junit.framework.Assert.failNotEquals(Assert.java:282)
04-18 16:03:47.132: I/TestRunner(12376):    at junit.framework.Assert.assertEquals(Assert.java:64)
04-18 16:03:47.132: I/TestRunner(12376):    at junit.framework.Assert.assertEquals(Assert.java:71)
04-18 16:03:47.132: I/TestRunner(12376):    at com.crumbs.main.test.LoginActivityTest.testText(LoginActivityTest.java:46)
04-18 16:03:47.132: I/TestRunner(12376):    at java.lang.reflect.Method.invokeNative(Native Method)
04-18 16:03:47.132: I/TestRunner(12376):    at java.lang.reflect.Method.invoke(Method.java:507)
04-18 16:03:47.132: I/TestRunner(12376):    at android.test.InstrumentationTestCase.runMethod(InstrumentationTestCase.java:204)
04-18 16:03:47.132: I/TestRunner(12376):    at android.test.InstrumentationTestCase.runTest(InstrumentationTestCase.java:194)
04-18 16:03:47.132: I/TestRunner(12376):    at android.test.ActivityInstrumentationTestCase2.runTest(ActivityInstrumentationTestCase2.java:186)
04-18 16:03:47.132: I/TestRunner(12376):    at junit.framework.TestCase.runBare(TestCase.java:127)
04-18 16:03:47.132: I/TestRunner(12376):    at junit.framework.TestResult$1.protect(TestResult.java:106)
04-18 16:03:47.132: I/TestRunner(12376):    at junit.framework.TestResult.runProtected(TestResult.java:124)
04-18 16:03:47.132: I/TestRunner(12376):    at junit.framework.TestResult.run(TestResult.java:109)
04-18 16:03:47.132: I/TestRunner(12376):    at junit.framework.TestCase.run(TestCase.java:118)
04-18 16:03:47.132: I/TestRunner(12376):    at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:169)
04-18 16:03:47.132: I/TestRunner(12376):    at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:154)
04-18 16:03:47.132: I/TestRunner(12376):    at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:529)
04-18 16:03:47.132: I/TestRunner(12376):    at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1448)

How do I test it then? As in, how do I set the values for the EditText so that I can test it here?

The documentation is a bit scattered.

  • 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-02T00:33:12+00:00Added an answer on June 2, 2026 at 12:33 am

    it is working just fine.. Its just saying your test case failed because the text in the EditText is not equal to text your comparing to..
    try this/..

         @Override
                protected void setUp() throws Exception {
                      super.setUp();
                      mActivity = this.getActivity();
    
                      username = (EditText) mActivity.findViewById(R.id.username);
                      password = (EditText) mActivity.findViewById(R.id.password);
    
    
                              }
    
                  public void testPreconditions() { 
                      assertNotNull(username);
                      assertNotNull(password);
                    }
    
    
                  public void testText() {
    //now that it will pass the test case without Exception..
    //but if you want to compare text then you may have to set it in xml and then compare it.. doing it in onCreate() of Login may also work.. 
                      assertEquals("",username.getText());
                      assertEquals("", password.getText());
                    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

public class SettingsActivity extends PreferenceActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); /*
public class BobDatabase extends SQLiteOpenHelper{ private static final String DATABASE_NAME = bob.db; private static
public class GenericDao <T, PK extends Serializable> { private final Class<T> type; @Resource(name =
public class upload extends Activity { private static final int CAMERA_REQUEST = 1888; private
public class PackageTabActivity extends ListActivity{ HashMap<String,Object> hm ; ArrayList<HashMap<String,Object>> applistwithicon ; private static final
public class Offer_Popup extends Activity { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.offer_popup); //newly
public class SuperUser extends User implements Serializable{ private static final long serialVersionUID = 1L;
public class WordDisplay extends Activity { private int level; private int group; private int
public class Greeter extends MovieClip { public function Greeter() { addEventListener(Event.ADDED_TO_STAGE, go); } private
public class master extends Activity { ProgressDialog progressDialog; EditText tahmini_kelime; EditText girilen_sayi ; EditText

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.