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

  • Home
  • SEARCH
  • 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 5963733
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T19:18:22+00:00 2026-05-22T19:18:22+00:00

Are we supposed to write tests for our getters and setters or is it

  • 0

Are we supposed to write tests for our getters and setters or is it overkill?

  • 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-22T19:18:23+00:00Added an answer on May 22, 2026 at 7:18 pm

    I would say no.

    @Will said you should aim for 100% code coverage, but in my opinion that’s a dangerous distraction. You can write unit tests that have 100% coverage, and yet test absolutely nothing.

    Unit tests are there to test the behaviour of your code, in an expressive and meaningful way, and getters/setters are only a means to an end. If you tests use the getters/setters to achieve their goal of testing the “real” functionality, then that’s good enough.

    If, on the other hand, your getters and setters do more than just get and set (i.e. they’re properly complex methods), then yes, they should be tested. But don’t write a unit test case just to test a getter or setters, that’s a waste of time.

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

Sidebar

Related Questions

I'm supposed to write unit tests for a project whose code another colleague has
Java is supposed to be write once, run anywhere and it really can be,
I need to write a java script. This is supposed to validate if the
Are we supposed to find workarounds in our web applications so that they will
I wrote this function that's supposed to do StringPadRight("Hello", 10, "0") -> "Hello00000" .
Would it suppose any difference regarding overhead to write an import loading all the
Suppose I am writing an application in C++ and C#. I want to write
I'm supposed to create a simple rule engine in C#. Any leads on how
I'm hoping someone can help me see the real value in these tests because
I've been tasked to write a small app to be used by a single

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.