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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T22:12:15+00:00 2026-05-11T22:12:15+00:00

I was experimenting jMock as my mocking framework for my project. I came into

  • 0

I was experimenting jMock as my mocking framework for my project. I came into a situation where I need to mock both a class and an interface. I used the ClassImposteriser.INSTANCE to initiate the impostor of the context.

Supposing a class Validator and an interface Person to mock. When I was going to mock the Interface Person, I ran to a problem NoClassFoundDefError. When I mocked the class Validator, there was no problem.

I need both that class and interface but I can’t solve the problem.
Please HELP.

Code Example:

Mockery

private Mockery context = new JUnit4Mockery() {{ setImposteriser(ClassImposteriser.Class) }};

Class :

private Validator validator;

Interface :

private Person person;

Inside Test Method

validator = context.Mock(Validator.class); —-> Working

person = context.Mock(Person.class); —-> NoClassFoundDefError

  • 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-11T22:12:15+00:00Added an answer on May 11, 2026 at 10:12 pm

    The code as you present it won’t compile (it should be ClassImposteriser.INSTANCE). The example code below seems to work fine. Perhaps you could provide some more details?

    public class Example {
        private Mockery context = new JUnit4Mockery() {
        {
            setImposteriser(ClassImposteriser.INSTANCE);
        }
        };
    
        @Test
        public void testStuff() {
        Validator validator = context.mock(Validator.class);
        Person person = context.mock(Person.class);
    
        // do some stuff...
        }
    
        public static interface Person {
        }
    
        public static class Validator {
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Just experimenting I've used this query on MySQL: insert into table_name (text_col) values (1919191919191919191919191...91919191)
I'm experimenting with ASP.Net Web API, which, by convention, splits controller methods into a
I am experimenting with embedding my pure offline mobile HTML5 ebook reader (http://www.hyper-books.com/) into
Experimenting with new features of T-SQL, I've run into a puzzle. Here is some
I experimenting with Flex Styling, and I came across an alignment issue. I have
Just experimenting with different inheritance techniques in JS, and came across something mildly discomfiting
Was experimenting with interface inheritance and found this: interface String{} interface Object{} interface Exception{}
Recently I've been experimenting with the use of the Func<T> class, and so far
I'm experimenting with writing a wrapper class for SQLite to be exposed through a
I've been reading up on (and experimenting with) several Java mocking APIs such 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.