I'm trying to mock a method to have it return one specific object:
private static final String PARAM = "somevalue";
...
@Test
public void jmockit() {
final PojoClass dfault = new PojoClass();
new NonStrictExpectations() {
StaticFacade mcfg;
{
StaticFacade.getPojo(PARAM); returns(dfault);
}
};
PojoClass a = StaticFacade.getPojo(PARAM);
assertNotNull(a);
}
But I'm facing 2 issues:
I'm using JDK1.5. Any ideas?
So looks like in the end it was a setup issue: I had an older version of JMockit and a eclipse signed JUnit jar. Updating the jars to the latest versions (Jmockit 0.999-12 and JUnit 4.10) fixed the issue.