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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T15:35:50+00:00 2026-05-31T15:35:50+00:00

Mockito keeps intercepting a function I made in a DAO and randomly returning 0.

  • 0

Mockito keeps intercepting a function I made in a DAO and randomly returning 0. I would like for the function to actually run. Where can I configure this mockito beast to leave the function alone?

Debugger jumps in here instead of going into my spring dao:

 public Object intercept(Object proxy, Method method, Object[] args, MethodProxy methodProxy)
        throws Throwable {
    if (objectMethodsGuru.isEqualsMethod(method)) {
        return proxy == args[0];
    } else if (objectMethodsGuru.isHashCodeMethod(method)) {
        return hashCodeForMock(proxy);
    }

    MockitoMethodProxy mockitoMethodProxy = createMockitoMethodProxy(methodProxy);
    cglibHacker.setMockitoNamingPolicy(mockitoMethodProxy);

    MockitoMethod mockitoMethod = createMockitoMethod(method);

    FilteredCGLIBProxyRealMethod realMethod = new FilteredCGLIBProxyRealMethod(mockitoMethodProxy);
    Invocation invocation = new Invocation(proxy, mockitoMethod, args, SequenceNumber.next(), realMethod);
    return handler.handle(invocation);
}
  • 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-31T15:35:52+00:00Added an answer on May 31, 2026 at 3:35 pm

    What is mockito?

    MockIto (and JMockIt as I took the original question) are mock APIs, they allow developers to write tests which are isolated from the rest of the application or other external resources (such as a database).

    why is it screwing with my JUNIT tests?

    As who ever wrote the test decided they do not want this test to hit the database. So they used mockito to prevent this from happening.

    Where can i configure this mockito beast to leave the function alone?

    Find the developer who wrote this test (or the test you are basing your current test on). Work with them to understand mocking frameworks.

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

Sidebar

Related Questions

I would like to do a test like: http://stevelibonati.wordpress.com/2012/02/05/spring-mvc-test-with-a-sprinkle-of-mockito/ My problem is that I
Consider a method signature like: public String myFunction(String abc); Can Mockito help return the
With Mockito I can do the following: verify(someService).process(any(Person.class)); But how do I write this
I've got a Mockito test that looks a bit like this (simplified, of course):
I'm looking for a mail server mock that can be configured like a Mockito
I am new to Mockito. Given the class below, how can I use Mockito
Can I use Mockito to capture what was passed to the HttpServletResponse#sendError() method? I
I am trying to mock a class using Mockito and also using PowerMock. This
I'm using Mockito for my unit testing, and I've run across an issue where
How do I write a Mockito-based JUnit method to test this method adduser() ?

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.