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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T00:11:27+00:00 2026-05-30T00:11:27+00:00

In the test project for my android app I initially had a series of

  • 0

In the test project for my android app I initially had a series of test for several low level classes. By low level I mean that they are not activities, services or anything specific. They are just classes performing some work according to specs. They relay though on some information from the app context – database, some resources etc.

All tests were green and I was happy. After I added another test class to the lineup to test an Activity all of the sudden my green test started to fail. The Activity tests I added are green but some of the tests which used to be green now throw an exception.

From the dalvik trace it looks like that although my used-to-be green tests do not need anything but the application context, the system still tries to resume some activity (not the one I was trying to unit test with the new tests).

So here is my question: how can I unit test a class which needs just the application context but nothing else? How can I prevent the runtime from trying to launch activities I care nothing about?

  • 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-30T00:11:28+00:00Added an answer on May 30, 2026 at 12:11 am

    Is sounds like you want to strip out Android from your unit tests. It would be nice if you could use Mocks for this, but unfortunately if you get the Android framework involved, you run into all sorts of problems trying to mock things.

    I highly recommend you use Robolectric to “defang” android, and use Mockito to mock stuff you don’t care about. This will allow you to continue to run your unit tests (I’m making an assumption here) on the JVM.

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

Sidebar

Related Questions

We had a test project that started out as MbUnit v3 / Gallio but
i want to import an existing Android Project(a small App that should be added
I'm setting up OAuth for my Android app. To test it I did the
I've added several dependencies in my Android project in IntelliJ, for unit-tests ( JUnit4
I have an android lib project, and an android test project i've built in
In my android project I have several images int the drawable folder with a
First to explain how projects are setup: Android Library project with two classes: UserActivity
When I start my separate android test project via 'android junit test' I always
I am using eclipse and I created a test android project and the package
I started writing my first Android app, and chose SDK 2.0.1, before I had

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.