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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T06:18:35+00:00 2026-05-23T06:18:35+00:00

Possible Duplicate: What is the purpose of mock objects? I’m preparing a presentation and

  • 0

Possible Duplicate:
What is the purpose of mock objects?

I’m preparing a presentation and I need to get a better understanding of what mocking is, what is the purpose of using it, what are the common situations that I should use mock objects? I found out that there are a bunch of mocking frameworks out there. Do they all do the same thing or do I use a specific framework for specific testing purpose? What are the differences between these frameworks? Which one would you recommend for testing Java?

here are some stuff that I found:

1.MockingToolkitComparisonMatrix which seems biased.

2.What are mock objects in Java? This is a year old. I thought there might be some better answer today.

Thank you.

  • 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-23T06:18:35+00:00Added an answer on May 23, 2026 at 6:18 am

    The purpose of mocking is to allow you to test your application components in isolation. For example, if you have a service that uses a DAO, you want to be able to test your service without actually having to go to the database via the DAO. You would

    1) Test the DAO in isolation, and
    2) Mock the DAO in your service tests, so your service can be tested in isolation.

    Since your DAO has a clearly defined API, your mock DAO simulates that API. So if you have a findAll type method that your service calls, you can easily mock the DAO to expect a call to findAll and return the appropriate results.

    The purpose of all mocking frameworks is the same — to allow you to set up expectations and assert that those expectations were met in your tests. The details, however, are different between frameworks. I have used EasyMock in actual work environments, and played around with Mockito for answering a few questions on SO. Both are pretty nice. The cost of entry is fairly low — the idea is always to set up expectations, get the mock to return the results, and then to verify that the expectations were met. You might have to take a day or 2 to understand your mocking framework, but after that you should be able to be productive and figure out what you don’t know as you go.

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

Sidebar

Related Questions

Possible Duplicate: How do you send email from a Java app using Gmail? How
Possible Duplicate: What is the purpose of the expression “new String(…)” in Java? It's
Possible Duplicate: What is the purpose of the Assemblies node in Web.Config? I removed
Possible Duplicate: What is the purpose of the expression “new String(…)” in Java? I've
Possible Duplicate: What is the purpose of a marker interface? Is it bad practice
Possible Duplicate: Interfaces: Why cant I seem to grasp them? What is the purpose
Possible Duplicate: When is JavaScript’s eval() not evil? I know, generally using eval() is
Possible Duplicate: Why doesn't delete set the pointer to NULL? Is there any purpose
Possible Duplicate: What is the purpose of wrapping whole Javascript files in anonymous functions
Possible Duplicate: What is the purpose of the expression “new String(…)” in Java? What's

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.