This test used to work with JMockit 1.8, stopped working with JMockit 1.9
public class InetAddressTest {
@Injectable
private InetAddress mockInetAddress;
@Test
public void testInetAddressMock() throws Exception{
new NonStrictExpectations(InetAddress.class) {{
InetAddress.getLocalHost();
result = mockInetAddress;
}};
Assert.assertSame(InetAddress.getLocalHost(), mockInetAddress);
}
}
The problem here is that JMockit complains about the class being already mocked.
Class is already mocked: class java.net.InetAddress
This is fair enough, but what is the recommended approach when I need to mock a static method from a class while having an Injectable value as well?
This test used to work with JMockit 1.8, stopped working with JMockit 1.9
The problem here is that JMockit complains about the class being already mocked.
This is fair enough, but what is the recommended approach when I need to mock a static method from a class while having an
Injectablevalue as well?