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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T14:13:05+00:00 2026-05-15T14:13:05+00:00

I decided to add unit tests to existing project (quite big one). I am

  • 0

I decided to add unit tests to existing project (quite big one).
I am using “google toolbox for mac” for various type of STAssert… and OCMock framework.

But I think I’m testing wrong. For example, I have public function saveData, which doesn’t return anything and only change internal state of the object. Should I test it? Due to encapsulation principle – I don’t have to worry much about object implementation and I mustn’t depend on private variables (because they can change/be deleted in the future)

@implementation Foo
-(void) saveData {
 internalData_ = 88;
}

In real project this function saveData is 100 lines long and it’s change a lot of private variables of the class.

So, should I test it or not? I have a little previous experience in unit testing and cannot make decision by my own.

  • 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-15T14:13:06+00:00Added an answer on May 15, 2026 at 2:13 pm

    Does the internal state that gets changed affect any later calls on that object? If so, you should include it in a unit test like

    • Test a()
    • Do saveData()
    • Test a() again

    Even if not, it might be a good idea to unit test it. Not for determining whether other code will break by using this method, but for automatically testing the correct implementation of the method. Even though the method doesn’t return anything, it probably still has some kind of contract (“If I call it, this must happen”) and you should check if what should’ve happened, happened (e.g. a line added in a log file, or something).

    Now, how to check that if the method doesn’t return anything, is another question entirely. Ironically enough, that’s an implementation detail of the unit test.

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

Sidebar

Related Questions

I decided to add unit tests to my project and continue development in a
I'm new to xcode and objective-c. I also decided to add unit (logic) tests
I need to add unit tests for an existing solution with a lot of
I'm fairly new to the unit testing world, and I just decided to add
I decided to add a GUI to one of my scripts. The script is
I've decided to add an NSNumber attribute to one of my entities in core
I'm using Devise, and I've decided to add the lockable option after I've already
I have decided to add some validation to my combobox, what I'm trying to
I am currently coding an application then decided to add HoloEverywhere into my application.
My last company, which used 4.01 DOCTYPE exclusively, decided to add some new functionality

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.