views:

446

answers:

1

I am trying to mock java.awt.Toolkit.beep() using JMockit Expectations. I have the following code in my test case:

new Expectations() {
    Toolkit mock;

    {
        mock.beep();
    }
}.endRecording();

When I run the test case (JUnit 4), I get the following exception at the "new Expectations" line:

java.lang.ClassFormatError: Code attribute in native or abstract methods in class file $Mock

Any ideas?

A: 

The default jmock can only mock interface. To mock class, you need to following these instructions

Journeyman Programmer
JMockit, not JMock
Ralph