will_hunting will_hunting - 1 year ago 85
Java Question

How can I replace @MockClass, which was deprecated?

I have code, which is using old version of JMockit library.

@MockClass(realClass = SomeClass.class)
public class MockSomeClass {
public SomeClass it;

@Mock
public void $init(DataSource dataSource) {
Deencapsulation.setField(it, new MockDataSource());
}
}


How should I change
@MockClass
annotation?

Answer Source
public class MockSomeClass extends Mockup<SomeClass>{
    public SomeClass it;

    @Mock
    public void $init(DataSource dataSource) {
        Deencapsulation.setField(it, new MockDataSource());
    }
}