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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:02:16+00:00 2026-05-23T15:02:16+00:00

I have a problem with writing a test case for my app. At first

  • 0

I have a problem with writing a test case for my app.

At first maybe I’ll tell how the app works. The first screen is the login screen , after successful login, a new activity is shown and the user credentials are saved to SharedPreferences so that when the activity starts again and user hadn’t log out, the app starts on the second activity screen.

I want to test the first activity with the login. My main problem is how to test successful login. If the login and password are valid, an intent to the new activity is created and the new activity is started. My code for this method is shown below:

public void testLoginValid() throws Throwable {
    for(index = 0; index < validEmails.length; index++) {
        runTestOnUiThread(new Runnable() {
            @Override
            public void run() {
                emailEditView.setText(validEmails[index]);
                passwordEditView.setText(defaultPassword);
                logIn.performClick();
            }
        });
        getInstrumentation().waitForIdleSync();
        //how to check if the activity started and how to go back?
    }
}

Is this a good way to test such case? The problem is when the login is valid and it logs in, the rest of the test cases hang because the active activity has changed and I don’t know how to simulate it’s finish are something like this. How to do this? Or maybe I should write method for each of the logins (but I don’t think it is a good practice…). Thanks in advance for any help.

  • 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-23T15:02:17+00:00Added an answer on May 23, 2026 at 3:02 pm

    If your task is to test logging in, you may replace the actual new activity start by some mock action and check if this action starts. Hope this helps.

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

Sidebar

Related Questions

I was writing a test case out to tackle a bigger problem in my
First of all, I have to say, I'm new to mocking. So maybe I'm
I have problem in some JavaScript that I am writing where the Switch statement
I have a asp.net page I'm writing and I'm perplexed by this problem. I
When writing GUIs, I've frequently come over the following problem: Assume you have a
I have problem compilin this code..can anyone tell whats wrong with the syntax CREATE
I do not have problem as such but I am quite new to Ruby.
I've got a unit test I'm writing which seems to have some kind of
I have a new web app that is packaged as a WAR as part
I am writing a testing framework for my web app. The case is 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.