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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T12:00:18+00:00 2026-05-13T12:00:18+00:00

My development team has started to use Mockito and have classes that have been

  • 0

My development team has started to use Mockito and have classes that have been defined as ‘final’. I’ve read in Effective Java by Joshua Bloch and in the SO thread When to use final that all classes should use the final modifier. There have been some disagreement in the thread, but I do agree with the idea of forcing class composition unless inheritance makes sense.

What should I do when I want to test classes using a testing framework like Mockito that requires classes to not have the ‘final’ modifier? I’m hoping someone else has encountered similar issues during their development. What resolutions did your development team arrive on?

There are two obvious answers such as using JMock or remove the ‘final’ modifier on the classes we want to test, but we want to stick with one external testing framework (besides JUnit) and it may be hard to convince other developers to remove the ‘final’ modifier.

Thanks.

  • 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-13T12:00:19+00:00Added an answer on May 13, 2026 at 12:00 pm

    What do you need most:

    1. The ability to make sure that somebody doesn’t inherit from your class, OR
    2. The ability to make sure that your code is testable using your mocking framework of choice?

    Generally, I believe that you don’t need to enforce (1). For me, testability (2), is far more important. What fits your situation best?

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

Sidebar

Related Questions

My development team has been over-using the term deploy, and it seems to have
We have an internal software development team in my company that are building a
I have been trying to setup git for our web development team unsuccessfully. Some
My development team of four people has been facing this issue for some time
My current team has standardized on NetBeans for all of our Java development, and
I am working with a globally distributed development team that has to download builds
Part of the development team I work with has been given the challenge of
My development team has worked with subversion for quite some time. The way that
From what I saw on their Github page, the Rails development team has been
Our team has been given a legacy system for further maintenance and development. As

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.