How to mock the default constructor of the Date class with JMockit?
问题 I want to mock the default constructor of java.util.date so it does not construct a Date object representing the time when it was created, but always the same Date object (in my example below 31 Dec 2010). I tried doing this with JMockit and JUnit , but when executing my test below, the output is always Thu Jan 01 01:00:00 CET 1970 . So what is wrong with my mock of Date() ? import java.util.Date; import org.junit.*; import mockit.*; public class AppTest { @Before public void setUp() { Mockit