will_hunting will_hunting - 4 months ago 24
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
public class MockSomeClass extends Mockup<SomeClass>{
    public SomeClass it;

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