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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T09:11:25+00:00 2026-06-11T09:11:25+00:00

Have created an android test project and currently trying to write android unit tests

  • 0

Have created an android test project and currently trying to write android unit tests

now if you have a bunch of classes whose methods you are trying to test and you’ve been good and applied the principle of least access and made all your member variables private how do you then write effective unit tests?

In other words, my unit tests sit in a class outside of the class i am trying to test, so I can’t access any of the member variables in my assert statements

is there a workaround for this scenario where you want access to everything for testing purposes

please don’t tell me i have to write getters and setters for every member variable just so I can write some unit tests

(thinking about it, this is more a Java question than an android specific question)

  • 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-11T09:11:26+00:00Added an answer on June 11, 2026 at 9:11 am

    Interesting question… Although you might have to write getters/setters for every member variable. It could be worthwhile to put them inside a subclass that you only use for your testing, so you can easily preserve encapsulation in your production code.

    That’s the best solution I can think of.

    EDIT: Or you could make a duplicate class for testing, where you do a quick replace all ” private ” with ” public “.

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

Sidebar

Related Questions

I have android test project that i've integrated into the Hudson. I have created
I am currently trying to test the Android SDK/API, and to do so have
I have one Android Project. I created Junit test project for the same. I
I have created one Android Project with Ant build. And also created Test Project
My main project is an android library. I have created a test project with
I have created a MazeSolver android app for a school project. I am using
I have created one SMSapplication and i need to test it on my android
I have created my first project (after several tutorials and reading the Android Developers
I have created an android Flex project using Flash Builder 4.6. Initially the root
I am implementing Google Cloud Messaging service for android. I have created a test

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.